mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Merge branch 'srs.master'
This commit is contained in:
commit
aac6de69b4
4 changed files with 21 additions and 18 deletions
|
@ -26,6 +26,7 @@ gcc srs_flv_injecter.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_flv_i
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
|
@ -52,34 +52,35 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
rtmp = srs_rtmp_create(argv[1]);
|
rtmp = srs_rtmp_create(argv[1]);
|
||||||
|
|
||||||
printf("suck rtmp stream like rtmpdump\n");
|
srs_trace("suck rtmp stream like rtmpdump");
|
||||||
printf("srs(simple-rtmp-server) client librtmp library.\n");
|
srs_trace("srs(simple-rtmp-server) client librtmp library.");
|
||||||
printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision());
|
srs_trace("version: %d.%d.%d", srs_version_major(), srs_version_minor(), srs_version_revision());
|
||||||
printf("rtmp url: %s\n", argv[1]);
|
srs_trace("rtmp url: %s", argv[1]);
|
||||||
|
|
||||||
if (srs_simple_handshake(rtmp) != 0) {
|
if (srs_simple_handshake(rtmp) != 0) {
|
||||||
printf("simple handshake failed.\n");
|
srs_trace("simple handshake failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("simple handshake success\n");
|
srs_trace("simple handshake success");
|
||||||
|
|
||||||
if (srs_connect_app(rtmp) != 0) {
|
if (srs_connect_app(rtmp) != 0) {
|
||||||
printf("connect vhost/app failed.\n");
|
srs_trace("connect vhost/app failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("connect vhost/app success\n");
|
srs_trace("connect vhost/app success");
|
||||||
|
|
||||||
if (srs_play_stream(rtmp) != 0) {
|
if (srs_play_stream(rtmp) != 0) {
|
||||||
printf("play stream failed.\n");
|
srs_trace("play stream failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("play stream success\n");
|
srs_trace("play stream success");
|
||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) {
|
if (srs_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) {
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
printf("got packet: type=%s, time=%d, size=%d\n", srs_type2string(type), timestamp, size);
|
srs_trace("got packet: type=%s, time=%d, size=%d",
|
||||||
|
srs_type2string(type), timestamp, size);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
// undefine the log of librtmp for the srs use its log.
|
||||||
|
#undef srs_trace
|
||||||
|
#undef srs_verbose
|
||||||
|
|
||||||
#include <srs_kernel_error.hpp>
|
#include <srs_kernel_error.hpp>
|
||||||
#include <srs_protocol_rtmp.hpp>
|
#include <srs_protocol_rtmp.hpp>
|
||||||
#include <srs_lib_simple_socket.hpp>
|
#include <srs_lib_simple_socket.hpp>
|
||||||
|
|
|
@ -234,14 +234,11 @@ extern int srs_version_revision();
|
||||||
extern int64_t srs_get_time_ms();
|
extern int64_t srs_get_time_ms();
|
||||||
extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp);
|
extern int64_t srs_get_nsend_bytes(srs_rtmp_t rtmp);
|
||||||
extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
|
extern int64_t srs_get_nrecv_bytes(srs_rtmp_t rtmp);
|
||||||
// log to console.
|
|
||||||
|
// log to console, for use srs-librtmp application.
|
||||||
extern const char* srs_format_time();
|
extern const char* srs_format_time();
|
||||||
#ifndef srs_trace
|
#define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
||||||
#define srs_trace(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
#define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
||||||
#endif
|
|
||||||
#ifndef srs_verbose
|
|
||||||
#define srs_verbose(msg, ...) printf("[%s]", srs_format_time());printf(msg, ##__VA_ARGS__);printf("\n")
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*************************************************************
|
/*************************************************************
|
||||||
**************************************************************
|
**************************************************************
|
||||||
|
|
Loading…
Reference in a new issue