正在显示
4 个修改的文件
包含
20 行增加
和
9 行删除
@@ -50,6 +50,7 @@ int main(int argc, char** argv) | @@ -50,6 +50,7 @@ int main(int argc, char** argv) | ||
50 | 50 | ||
51 | // packet data | 51 | // packet data |
52 | int type, size; | 52 | int type, size; |
53 | + u_int32_t basetime = 0; | ||
53 | u_int32_t timestamp = 0; | 54 | u_int32_t timestamp = 0; |
54 | char* data; | 55 | char* data; |
55 | 56 | ||
@@ -131,8 +132,13 @@ int main(int argc, char** argv) | @@ -131,8 +132,13 @@ int main(int argc, char** argv) | ||
131 | } | 132 | } |
132 | printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size); | 133 | printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size); |
133 | 134 | ||
134 | - if (time_first_packet <= 0) { | ||
135 | - time_first_packet = srs_get_time_ms(); | 135 | + if (SRS_RTMP_TYPE_VIDEO == type || SRS_RTMP_TYPE_AUDIO == type) { |
136 | + if (time_first_packet <= 0) { | ||
137 | + time_first_packet = srs_get_time_ms(); | ||
138 | + } | ||
139 | + if (basetime <= 0) { | ||
140 | + basetime = timestamp; | ||
141 | + } | ||
136 | } | 142 | } |
137 | 143 | ||
138 | free(data); | 144 | free(data); |
@@ -142,7 +148,7 @@ int main(int argc, char** argv) | @@ -142,7 +148,7 @@ int main(int argc, char** argv) | ||
142 | goto rtmp_destroy; | 148 | goto rtmp_destroy; |
143 | } | 149 | } |
144 | 150 | ||
145 | - if (timestamp > duration * 1000) { | 151 | + if ((timestamp - basetime) > duration * 1000) { |
146 | printf("duration exceed, terminate.\n"); | 152 | printf("duration exceed, terminate.\n"); |
147 | goto rtmp_destroy; | 153 | goto rtmp_destroy; |
148 | } | 154 | } |
@@ -178,11 +184,11 @@ rtmp_destroy: | @@ -178,11 +184,11 @@ rtmp_destroy: | ||
178 | "start_play", (int)(time_play_stream - time_socket_connect), //#4 | 184 | "start_play", (int)(time_play_stream - time_socket_connect), //#4 |
179 | "first_packet", (int)(time_first_packet - time_play_stream), //#5 | 185 | "first_packet", (int)(time_first_packet - time_play_stream), //#5 |
180 | "last_packet", (int)(time_cleanup - time_first_packet), //#6 | 186 | "last_packet", (int)(time_cleanup - time_first_packet), //#6 |
181 | - "stream", (int)(timestamp), //#7 | 187 | + "stream", (int)(timestamp - basetime), //#7 |
182 | // expect = time_cleanup - time_first_packet | 188 | // expect = time_cleanup - time_first_packet |
183 | // actual = stream | 189 | // actual = stream |
184 | // delay = actual - expect | 190 | // delay = actual - expect |
185 | - "delay", (int)(timestamp - (time_cleanup - time_first_packet)), //#8 | 191 | + "delay", (int)(timestamp - basetime - (time_cleanup - time_first_packet)), //#8 |
186 | "publish_kbps", (int)((time_duration <= 0)? 0:(bytes_nsend * 8 / time_duration)), //#9 | 192 | "publish_kbps", (int)((time_duration <= 0)? 0:(bytes_nsend * 8 / time_duration)), //#9 |
187 | "play_kbps", (int)((time_duration <= 0)? 0:(bytes_nrecv * 8 / time_duration)), //#10 | 193 | "play_kbps", (int)((time_duration <= 0)? 0:(bytes_nrecv * 8 / time_duration)), //#10 |
188 | // unit in ms. | 194 | // unit in ms. |
@@ -34,9 +34,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -34,9 +34,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
34 | 34 | ||
35 | #include <srs_app_reload.hpp> | 35 | #include <srs_app_reload.hpp> |
36 | 36 | ||
37 | -// default vhost for rtmp | ||
38 | -#define RTMP_VHOST_DEFAULT "__defaultVhost__" | ||
39 | - | ||
40 | #define SRS_LOCALHOST "127.0.0.1" | 37 | #define SRS_LOCALHOST "127.0.0.1" |
41 | #define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid" | 38 | #define SRS_CONF_DEFAULT_PID_FILE "./objs/srs.pid" |
42 | #define SRS_DEFAULT_CONF "conf/srs.conf" | 39 | #define SRS_DEFAULT_CONF "conf/srs.conf" |
@@ -263,7 +263,12 @@ int srs_connect_app(srs_rtmp_t rtmp) | @@ -263,7 +263,12 @@ int srs_connect_app(srs_rtmp_t rtmp) | ||
263 | Context* context = (Context*)rtmp; | 263 | Context* context = (Context*)rtmp; |
264 | 264 | ||
265 | string tcUrl = "rtmp://"; | 265 | string tcUrl = "rtmp://"; |
266 | - tcUrl += context->vhost; | 266 | + // TODO: FIXME: extrace shared method |
267 | + if (context->vhost == RTMP_VHOST_DEFAULT) { | ||
268 | + tcUrl += context->ip; | ||
269 | + } else { | ||
270 | + tcUrl += context->vhost; | ||
271 | + } | ||
267 | tcUrl += ":"; | 272 | tcUrl += ":"; |
268 | tcUrl += context->port; | 273 | tcUrl += context->port; |
269 | tcUrl += "/"; | 274 | tcUrl += "/"; |
@@ -31,6 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -31,6 +31,9 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
31 | 31 | ||
32 | #include <string> | 32 | #include <string> |
33 | 33 | ||
34 | +// default vhost for rtmp | ||
35 | +#define RTMP_VHOST_DEFAULT "__defaultVhost__" | ||
36 | + | ||
34 | #define RTMP_DEFAULT_PORT "1935" | 37 | #define RTMP_DEFAULT_PORT "1935" |
35 | 38 | ||
36 | // the default chunk size for system. | 39 | // the default chunk size for system. |
-
请 注册 或 登录 后发表评论