正在显示
4 个修改的文件
包含
21 行增加
和
18 行删除
| @@ -26,6 +26,7 @@ gcc srs_flv_injecter.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_flv_i | @@ -26,6 +26,7 @@ gcc srs_flv_injecter.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_flv_i | ||
| 26 | 26 | ||
| 27 | #include <stdio.h> | 27 | #include <stdio.h> |
| 28 | #include <stdlib.h> | 28 | #include <stdlib.h> |
| 29 | +#include <string.h> | ||
| 29 | #include <unistd.h> | 30 | #include <unistd.h> |
| 30 | 31 | ||
| 31 | #include <sys/types.h> | 32 | #include <sys/types.h> |
| @@ -52,34 +52,35 @@ int main(int argc, char** argv) | @@ -52,34 +52,35 @@ int main(int argc, char** argv) | ||
| 52 | 52 | ||
| 53 | rtmp = srs_rtmp_create(argv[1]); | 53 | rtmp = srs_rtmp_create(argv[1]); |
| 54 | 54 | ||
| 55 | - printf("suck rtmp stream like rtmpdump\n"); | ||
| 56 | - printf("srs(simple-rtmp-server) client librtmp library.\n"); | ||
| 57 | - printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
| 58 | - printf("rtmp url: %s\n", argv[1]); | 55 | + srs_trace("suck rtmp stream like rtmpdump"); |
| 56 | + srs_trace("srs(simple-rtmp-server) client librtmp library."); | ||
| 57 | + srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
| 58 | + srs_trace("rtmp url: %s", argv[1]); | ||
| 59 | 59 | ||
| 60 | if (srs_simple_handshake(rtmp) != 0) { | 60 | if (srs_simple_handshake(rtmp) != 0) { |
| 61 | - printf("simple handshake failed.\n"); | 61 | + srs_trace("simple handshake failed."); |
| 62 | goto rtmp_destroy; | 62 | goto rtmp_destroy; |
| 63 | } | 63 | } |
| 64 | - printf("simple handshake success\n"); | 64 | + srs_trace("simple handshake success"); |
| 65 | 65 | ||
| 66 | if (srs_connect_app(rtmp) != 0) { | 66 | if (srs_connect_app(rtmp) != 0) { |
| 67 | - printf("connect vhost/app failed.\n"); | 67 | + srs_trace("connect vhost/app failed."); |
| 68 | goto rtmp_destroy; | 68 | goto rtmp_destroy; |
| 69 | } | 69 | } |
| 70 | - printf("connect vhost/app success\n"); | 70 | + srs_trace("connect vhost/app success"); |
| 71 | 71 | ||
| 72 | if (srs_play_stream(rtmp) != 0) { | 72 | if (srs_play_stream(rtmp) != 0) { |
| 73 | - printf("play stream failed.\n"); | 73 | + srs_trace("play stream failed."); |
| 74 | goto rtmp_destroy; | 74 | goto rtmp_destroy; |
| 75 | } | 75 | } |
| 76 | - printf("play stream success\n"); | 76 | + srs_trace("play stream success"); |
| 77 | 77 | ||
| 78 | for (;;) { | 78 | for (;;) { |
| 79 | if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { | 79 | if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { |
| 80 | goto rtmp_destroy; | 80 | goto rtmp_destroy; |
| 81 | } | 81 | } |
| 82 | - printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size); | 82 | + srs_trace("got packet: type=%s, time=%d, size=%d", |
| 83 | + srs_type2string(type), timestamp, size); | ||
| 83 | 84 | ||
| 84 | free(data); | 85 | free(data); |
| 85 | } | 86 | } |
| @@ -30,6 +30,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,6 +30,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | #include <sstream> | 30 | #include <sstream> |
| 31 | using namespace std; | 31 | using namespace std; |
| 32 | 32 | ||
| 33 | +// undefine the log of librtmp for the srs use its log. | ||
| 34 | +#undef srs_trace | ||
| 35 | +#undef srs_verbose | ||
| 36 | + | ||
| 33 | #include <srs_kernel_error.hpp> | 37 | #include <srs_kernel_error.hpp> |
| 34 | #include <srs_protocol_rtmp.hpp> | 38 | #include <srs_protocol_rtmp.hpp> |
| 35 | #include <srs_lib_simple_socket.hpp> | 39 | #include <srs_lib_simple_socket.hpp> |
| @@ -234,14 +234,11 @@ extern int srs_version_revision(); | @@ -234,14 +234,11 @@ extern int srs_version_revision(); | ||
| 234 | extern int64_t srs_get_time_ms(); | 234 | extern int64_t srs_get_time_ms(); |
| 235 | extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp); | 235 | extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp); |
| 236 | extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); | 236 | extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp); |
| 237 | -// log to console. | 237 | + |
| 238 | +// log to console, for use srs-librtmp application. | ||
| 238 | extern const char* srs_format_time(); | 239 | extern const char* srs_format_time(); |
| 239 | -#ifndef srs_trace | ||
| 240 | - #define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 241 | -#endif | ||
| 242 | -#ifndef srs_verbose | ||
| 243 | - #define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 244 | -#endif | 240 | +#define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") |
| 241 | +#define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n") | ||
| 245 | 242 | ||
| 246 | /************************************************************* | 243 | /************************************************************* |
| 247 | ************************************************************** | 244 | ************************************************************** |
-
请 注册 或 登录 后发表评论