srs-librtmp add rtmp prefix for rtmp apis. 2.0.29

pull/133/head
winlin 10 years ago
parent 180106ce70
commit aa69f6197a

@ -482,6 +482,7 @@ Supported operating systems and hardware:
* 2013-10-17, Created.<br/>
## History
* v2.0, 2014-11-21, srs-librtmp add rtmp prefix for rtmp/utils/human apis. 2.0.29.
* v2.0, 2014-11-21, refine examples of srs-librtmp, add srs_print_rtmp_packet. 2.0.28.
* v2.0, 2014-11-20, fix [#212](https://github.com/winlinvip/simple-rtmp-server/issues/212), support publish audio raw frames. 2.0.27
* v2.0, 2014-11-19, fix [#213](https://github.com/winlinvip/simple-rtmp-server/issues/213), support compile [srs-librtmp on windows](https://github.com/winlinvip/srs.librtmp), [bug #213](https://github.com/winlinvip/simple-rtmp-server/issues/213). 2.0.26

@ -116,19 +116,19 @@ int main(int argc, char** argv)
// connect rtmp context
srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url);
if (srs_simple_handshake(rtmp) != 0) {
if (srs_rtmp_handshake(rtmp) != 0) {
srs_human_trace("simple handshake failed.");
goto rtmp_destroy;
}
srs_human_trace("simple handshake success");
if (srs_connect_app(rtmp) != 0) {
if (srs_rtmp_connect_app(rtmp) != 0) {
srs_human_trace("connect vhost/app failed.");
goto rtmp_destroy;
}
srs_human_trace("connect vhost/app success");
if (srs_publish_stream(rtmp) != 0) {
if (srs_rtmp_publish_stream(rtmp) != 0) {
srs_human_trace("publish stream failed.");
goto rtmp_destroy;
}

@ -21,7 +21,7 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
/**
gcc srs_bandwidth_check.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_bandwidth_check
gcc srs_rtmp_bandwidth_check.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_rtmp_bandwidth_check
*/
#include <stdio.h>
@ -83,20 +83,20 @@ int main(int argc, char** argv)
srs_human_trace("bandwidth check/test url: %s", argv[1]);
if ((ret = srs_simple_handshake(rtmp)) != 0) {
if ((ret = srs_rtmp_handshake(rtmp)) != 0) {
srs_human_trace("simple handshake failed.");
goto rtmp_destroy;
}
srs_human_trace("simple handshake success");
if ((ret = srs_connect_app2(rtmp,
if ((ret = srs_rtmp_connect_app2(rtmp,
srs_server_ip, srs_server, srs_primary_authors, srs_version, &srs_id, &srs_pid)) != 0) {
srs_human_trace("connect vhost/app failed.");
goto rtmp_destroy;
}
srs_human_trace("connect vhost/app success");
if ((ret = srs_bandwidth_check(rtmp,
if ((ret = srs_rtmp_bandwidth_check(rtmp,
&start_time, &end_time, &play_kbps, &publish_kbps,
&play_bytes, &publish_bytes, &play_duration, &publish_duration)) != 0
) {

@ -90,33 +90,33 @@ int main(int argc, char** argv)
rtmp = srs_rtmp_create(rtmp_url);
if ((ret = __srs_dns_resolve(rtmp)) != 0) {
if ((ret = __srs_rtmp_dns_resolve(rtmp)) != 0) {
srs_human_trace("dns resolve failed. ret=%d", ret);
goto rtmp_destroy;
}
srs_human_trace("dns resolve success");
time_dns_resolve = srs_utils_get_time_ms();
if ((ret = __srs_connect_server(rtmp)) != 0) {
if ((ret = __srs_rtmp_connect_server(rtmp)) != 0) {
srs_human_trace("socket connect failed. ret=%d", ret);
goto rtmp_destroy;
}
srs_human_trace("socket connect success");
time_socket_connect = srs_utils_get_time_ms();
if ((ret = __srs_do_simple_handshake(rtmp)) != 0) {
if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != 0) {
srs_human_trace("do simple handshake failed. ret=%d", ret);
goto rtmp_destroy;
}
srs_human_trace("do simple handshake success");
if ((ret = srs_connect_app(rtmp)) != 0) {
if ((ret = srs_rtmp_connect_app(rtmp)) != 0) {
srs_human_trace("connect vhost/app failed. ret=%d", ret);
goto rtmp_destroy;
}
srs_human_trace("connect vhost/app success");
if ((ret = srs_play_stream(rtmp)) != 0) {
if ((ret = srs_rtmp_play_stream(rtmp)) != 0) {
srs_human_trace("play stream failed. ret=%d", ret);
goto rtmp_destroy;
}
@ -124,7 +124,7 @@ int main(int argc, char** argv)
time_play_stream = srs_utils_get_time_ms();
for (;;) {
if ((ret = srs_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) {
if ((ret = srs_rtmp_read_packet(rtmp, &type, &timestamp, &data, &size)) != 0) {
srs_human_trace("read packet failed. ret=%d", ret);
goto rtmp_destroy;
}

@ -128,19 +128,19 @@ int main(int argc, char** argv)
// connect rtmp context
srs_rtmp_t rtmp = srs_rtmp_create(rtmp_url);
if (srs_simple_handshake(rtmp) != 0) {
if (srs_rtmp_handshake(rtmp) != 0) {
srs_human_trace("simple handshake failed.");
goto rtmp_destroy;
}
srs_human_trace("simple handshake success");
if (srs_connect_app(rtmp) != 0) {
if (srs_rtmp_connect_app(rtmp) != 0) {
srs_human_trace("connect vhost/app failed.");
goto rtmp_destroy;
}
srs_human_trace("connect vhost/app success");
if (srs_publish_stream(rtmp) != 0) {
if (srs_rtmp_publish_stream(rtmp) != 0) {
srs_human_trace("publish stream failed.");
goto rtmp_destroy;
}

@ -148,7 +148,7 @@ int do_proxy(srs_flv_t flv, srs_rtmp_t ortmp, int64_t re, int32_t* pstarttime, u
return ret;
}
if ((ret = srs_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) {
if ((ret = srs_rtmp_write_packet(ortmp, type, *ptimestamp, data, size)) != 0) {
srs_human_trace("irtmp get packet failed. ret=%d", ret);
return ret;
}
@ -191,19 +191,19 @@ int connect_oc(srs_rtmp_t ortmp)
{
int ret = 0;
if ((ret = srs_simple_handshake(ortmp)) != 0) {
if ((ret = srs_rtmp_handshake(ortmp)) != 0) {
srs_human_trace("ortmp simple handshake failed. ret=%d", ret);
return ret;
}
srs_human_trace("ortmp simple handshake success");
if ((ret = srs_connect_app(ortmp)) != 0) {
if ((ret = srs_rtmp_connect_app(ortmp)) != 0) {
srs_human_trace("ortmp connect vhost/app failed. ret=%d", ret);
return ret;
}
srs_human_trace("ortmp connect vhost/app success");
if ((ret = srs_publish_stream(ortmp)) != 0) {
if ((ret = srs_rtmp_publish_stream(ortmp)) != 0) {
srs_human_trace("ortmp publish stream failed. ret=%d", ret);
return ret;
}

@ -108,7 +108,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
srs_human_trace("start proxy RTMP stream");
for (;;) {
if ((ret = srs_read_packet(irtmp, &type, &timestamp, &data, &size)) != 0) {
if ((ret = srs_rtmp_read_packet(irtmp, &type, &timestamp, &data, &size)) != 0) {
srs_human_trace("irtmp get packet failed. ret=%d", ret);
return ret;
}
@ -118,7 +118,7 @@ int proxy(srs_rtmp_t irtmp, srs_rtmp_t ortmp)
return ret;
}
if ((ret = srs_write_packet(ortmp, type, timestamp, data, size)) != 0) {
if ((ret = srs_rtmp_write_packet(ortmp, type, timestamp, data, size)) != 0) {
srs_human_trace("irtmp get packet failed. ret=%d", ret);
return ret;
}
@ -133,19 +133,19 @@ int connect_ic(srs_rtmp_t irtmp)
{
int ret = 0;
if ((ret = srs_simple_handshake(irtmp)) != 0) {
if ((ret = srs_rtmp_handshake(irtmp)) != 0) {
srs_human_trace("irtmp simple handshake failed. ret=%d", ret);
return ret;
}
srs_human_trace("irtmp simple handshake success");
if ((ret = srs_connect_app(irtmp)) != 0) {
if ((ret = srs_rtmp_connect_app(irtmp)) != 0) {
srs_human_trace("irtmp connect vhost/app failed. ret=%d", ret);
return ret;
}
srs_human_trace("irtmp connect vhost/app success");
if ((ret = srs_play_stream(irtmp)) != 0) {
if ((ret = srs_rtmp_play_stream(irtmp)) != 0) {
srs_human_trace("irtmp play stream failed. ret=%d", ret);
return ret;
}
@ -158,19 +158,19 @@ int connect_oc(srs_rtmp_t ortmp)
{
int ret = 0;
if ((ret = srs_simple_handshake(ortmp)) != 0) {
if ((ret = srs_rtmp_handshake(ortmp)) != 0) {
srs_human_trace("ortmp simple handshake failed. ret=%d", ret);
return ret;
}
srs_human_trace("ortmp simple handshake success");
if ((ret = srs_connect_app(ortmp)) != 0) {
if ((ret = srs_rtmp_connect_app(ortmp)) != 0) {
srs_human_trace("ortmp connect vhost/app failed. ret=%d", ret);
return ret;
}
srs_human_trace("ortmp connect vhost/app success");
if ((ret = srs_publish_stream(ortmp)) != 0) {
if ((ret = srs_rtmp_publish_stream(ortmp)) != 0) {
srs_human_trace("ortmp publish stream failed. ret=%d", ret);
return ret;
}

@ -47,19 +47,19 @@ int main(int argc, char** argv)
srs_human_trace("rtmp url: %s", argv[1]);
srs_rtmp_t rtmp = srs_rtmp_create(argv[1]);
if (srs_simple_handshake(rtmp) != 0) {
if (srs_rtmp_handshake(rtmp) != 0) {
srs_human_trace("simple handshake failed.");
goto rtmp_destroy;
}
srs_human_trace("simple handshake success");
if (srs_connect_app(rtmp) != 0) {
if (srs_rtmp_connect_app(rtmp) != 0) {
srs_human_trace("connect vhost/app failed.");
goto rtmp_destroy;
}
srs_human_trace("connect vhost/app success");
if (srs_play_stream(rtmp) != 0) {
if (srs_rtmp_play_stream(rtmp) != 0) {
srs_human_trace("play stream failed.");
goto rtmp_destroy;
}
@ -71,7 +71,7 @@ int main(int argc, char** argv)
char* data;
u_int32_t timestamp;
if (srs_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) {
if (srs_rtmp_read_packet(rtmp, &type, &timestamp, &data, &size) != 0) {
goto rtmp_destroy;
}

@ -55,19 +55,19 @@ int main(int argc, char** argv)
srs_human_trace("rtmp url: %s", argv[1]);
srs_rtmp_t rtmp = srs_rtmp_create(argv[1]);
if (srs_simple_handshake(rtmp) != 0) {
if (srs_rtmp_handshake(rtmp) != 0) {
srs_human_trace("simple handshake failed.");
goto rtmp_destroy;
}
srs_human_trace("simple handshake success");
if (srs_connect_app(rtmp) != 0) {
if (srs_rtmp_connect_app(rtmp) != 0) {
srs_human_trace("connect vhost/app failed.");
goto rtmp_destroy;
}
srs_human_trace("connect vhost/app success");
if (srs_publish_stream(rtmp) != 0) {
if (srs_rtmp_publish_stream(rtmp) != 0) {
srs_human_trace("publish stream failed.");
goto rtmp_destroy;
}
@ -81,7 +81,7 @@ int main(int argc, char** argv)
timestamp += 40;
if (srs_write_packet(rtmp, type, timestamp, data, size) != 0) {
if (srs_rtmp_write_packet(rtmp, type, timestamp, data, size) != 0) {
goto rtmp_destroy;
}
srs_human_trace("sent packet: type=%s, time=%d, size=%d",

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version
#define VERSION_MAJOR 2
#define VERSION_MINOR 0
#define VERSION_REVISION 28
#define VERSION_REVISION 29
// server info.
#define RTMP_SIG_SRS_KEY "SRS"
#define RTMP_SIG_SRS_ROLE "origin/edge server"

@ -514,6 +514,21 @@ int srs_librtmp_context_connect(Context* context)
extern "C"{
#endif
int srs_version_major()
{
return VERSION_MAJOR;
}
int srs_version_minor()
{
return VERSION_MINOR;
}
int srs_version_revision()
{
return VERSION_REVISION;
}
srs_rtmp_t srs_rtmp_create(const char* url)
{
Context* context = new Context();
@ -541,26 +556,26 @@ void srs_rtmp_destroy(srs_rtmp_t rtmp)
srs_freep(context);
}
int srs_simple_handshake(srs_rtmp_t rtmp)
int srs_rtmp_handshake(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
if ((ret = __srs_dns_resolve(rtmp)) != ERROR_SUCCESS) {
if ((ret = __srs_rtmp_dns_resolve(rtmp)) != ERROR_SUCCESS) {
return ret;
}
if ((ret = __srs_connect_server(rtmp)) != ERROR_SUCCESS) {
if ((ret = __srs_rtmp_connect_server(rtmp)) != ERROR_SUCCESS) {
return ret;
}
if ((ret = __srs_do_simple_handshake(rtmp)) != ERROR_SUCCESS) {
if ((ret = __srs_rtmp_do_simple_handshake(rtmp)) != ERROR_SUCCESS) {
return ret;
}
return ret;
}
int __srs_dns_resolve(srs_rtmp_t rtmp)
int __srs_rtmp_dns_resolve(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
@ -579,7 +594,7 @@ int __srs_dns_resolve(srs_rtmp_t rtmp)
return ret;
}
int __srs_connect_server(srs_rtmp_t rtmp)
int __srs_rtmp_connect_server(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
@ -593,7 +608,7 @@ int __srs_connect_server(srs_rtmp_t rtmp)
return ret;
}
int __srs_do_simple_handshake(srs_rtmp_t rtmp)
int __srs_rtmp_do_simple_handshake(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
@ -613,7 +628,7 @@ int __srs_do_simple_handshake(srs_rtmp_t rtmp)
return ret;
}
int srs_connect_app(srs_rtmp_t rtmp)
int srs_rtmp_connect_app(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
@ -634,7 +649,7 @@ int srs_connect_app(srs_rtmp_t rtmp)
return ret;
}
int srs_connect_app2(srs_rtmp_t rtmp,
int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
char srs_server_ip[128],char srs_server[128], char srs_primary_authors[128],
char srs_version[32], int* srs_id, int* srs_pid
) {
@ -670,7 +685,7 @@ int srs_connect_app2(srs_rtmp_t rtmp,
return ret;
}
int srs_play_stream(srs_rtmp_t rtmp)
int srs_rtmp_play_stream(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
@ -687,7 +702,7 @@ int srs_play_stream(srs_rtmp_t rtmp)
return ret;
}
int srs_publish_stream(srs_rtmp_t rtmp)
int srs_rtmp_publish_stream(srs_rtmp_t rtmp)
{
int ret = ERROR_SUCCESS;
@ -701,7 +716,7 @@ int srs_publish_stream(srs_rtmp_t rtmp)
return ret;
}
int srs_bandwidth_check(srs_rtmp_t rtmp,
int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp,
int64_t* start_time, int64_t* end_time,
int* play_kbps, int* publish_kbps,
int* play_bytes, int* publish_bytes,
@ -737,7 +752,7 @@ int srs_bandwidth_check(srs_rtmp_t rtmp,
return ret;
}
int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** data, int* size)
int srs_rtmp_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** data, int* size)
{
*type = 0;
*timestamp = 0;
@ -792,7 +807,7 @@ int srs_read_packet(srs_rtmp_t rtmp, char* type, u_int32_t* timestamp, char** da
return ret;
}
int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data, int size)
int srs_rtmp_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data, int size)
{
int ret = ERROR_SUCCESS;
@ -843,21 +858,6 @@ int srs_write_packet(srs_rtmp_t rtmp, char type, u_int32_t timestamp, char* data
return ret;
}
int srs_version_major()
{
return VERSION_MAJOR;
}
int srs_version_minor()
{
return VERSION_MINOR;
}
int srs_version_revision()
{
return VERSION_REVISION;
}
struct FlvContext
{
SrsFileReader reader;
@ -1356,7 +1356,7 @@ int srs_audio_write_raw_frame(srs_rtmp_t rtmp,
memcpy(p, frame, frame_size);
return srs_write_packet(context, SRS_RTMP_TYPE_AUDIO, timestamp, data, size);
return srs_rtmp_write_packet(context, SRS_RTMP_TYPE_AUDIO, timestamp, data, size);
}
/**
@ -1403,7 +1403,7 @@ int __srs_write_h264_packet(Context* context,
// h.264 raw data.
memcpy(p, h264_raw_data, h264_raw_size);
return srs_write_packet(context, SRS_RTMP_TYPE_VIDEO, timestamp, data, size);
return srs_rtmp_write_packet(context, SRS_RTMP_TYPE_VIDEO, timestamp, data, size);
}
/**

@ -84,6 +84,15 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
extern "C"{
#endif
/*************************************************************
**************************************************************
* srs-librtmp version
**************************************************************
*************************************************************/
extern int srs_version_major();
extern int srs_version_minor();
extern int srs_version_revision();
/*************************************************************
**************************************************************
* RTMP protocol context
@ -134,19 +143,19 @@ extern void srs_rtmp_destroy(srs_rtmp_t rtmp);
* not depends on ssl.
*/
/**
* srs_simple_handshake equals to invoke:
* __srs_dns_resolve()
* __srs_connect_server()
* __srs_do_simple_handshake()
* srs_rtmp_handshake equals to invoke:
* __srs_rtmp_dns_resolve()
* __srs_rtmp_connect_server()
* __srs_rtmp_do_simple_handshake()
* user can use these functions if needed.
*/
extern int srs_simple_handshake(srs_rtmp_t rtmp);
extern int srs_rtmp_handshake(srs_rtmp_t rtmp);
// parse uri, create socket, resolve host
extern int __srs_dns_resolve(srs_rtmp_t rtmp);
extern int __srs_rtmp_dns_resolve(srs_rtmp_t rtmp);
// connect socket to server
extern int __srs_connect_server(srs_rtmp_t rtmp);
extern int __srs_rtmp_connect_server(srs_rtmp_t rtmp);
// do simple handshake over socket.
extern int __srs_do_simple_handshake(srs_rtmp_t rtmp);
extern int __srs_rtmp_do_simple_handshake(srs_rtmp_t rtmp);
/**
* connect to rtmp vhost/app
@ -156,7 +165,7 @@ extern int __srs_do_simple_handshake(srs_rtmp_t rtmp);
*
* @return 0, success; otherswise, failed.
*/
extern int srs_connect_app(srs_rtmp_t rtmp);
extern int srs_rtmp_connect_app(srs_rtmp_t rtmp);
/**
* connect to server, get the debug srs info.
@ -171,7 +180,7 @@ extern int srs_connect_app(srs_rtmp_t rtmp);
*
* @return 0, success; otherswise, failed.
*/
extern int srs_connect_app2(srs_rtmp_t rtmp,
extern int srs_rtmp_connect_app2(srs_rtmp_t rtmp,
char srs_server_ip[128], char srs_server[128], char srs_primary_authors[128],
char srs_version[32], int* srs_id, int* srs_pid
);
@ -183,7 +192,7 @@ extern int srs_connect_app2(srs_rtmp_t rtmp,
* next: destroy
* @return 0, success; otherwise, failed.
*/
extern int srs_play_stream(srs_rtmp_t rtmp);
extern int srs_rtmp_play_stream(srs_rtmp_t rtmp);
/**
* publish a live stream.
@ -192,7 +201,7 @@ extern int srs_play_stream(srs_rtmp_t rtmp);
* next: destroy
* @return 0, success; otherwise, failed.
*/
extern int srs_publish_stream(srs_rtmp_t rtmp);
extern int srs_rtmp_publish_stream(srs_rtmp_t rtmp);
/**
* do bandwidth check with srs server.
@ -209,7 +218,7 @@ extern int srs_publish_stream(srs_rtmp_t rtmp);
*
* @return 0, success; otherswise, failed.
*/
extern int srs_bandwidth_check(srs_rtmp_t rtmp,
extern int srs_rtmp_bandwidth_check(srs_rtmp_t rtmp,
int64_t* start_time, int64_t* end_time,
int* play_kbps, int* publish_kbps,
int* play_bytes, int* publish_bytes,
@ -246,23 +255,13 @@ extern int srs_bandwidth_check(srs_rtmp_t rtmp,
*
* @return 0, success; otherswise, failed.
*/
extern int srs_read_packet(srs_rtmp_t rtmp,
extern int srs_rtmp_read_packet(srs_rtmp_t rtmp,
char* type, u_int32_t* timestamp, char** data, int* size
);
extern int srs_write_packet(srs_rtmp_t rtmp,
extern int srs_rtmp_write_packet(srs_rtmp_t rtmp,
char type, u_int32_t timestamp, char* data, int size
);
/*************************************************************
**************************************************************
* version apis
**************************************************************
*************************************************************/
// get protocol stack version
extern int srs_version_major();
extern int srs_version_minor();
extern int srs_version_revision();
/*************************************************************
**************************************************************
* flv codec
@ -607,7 +606,7 @@ extern int64_t srs_utils_get_recv_bytes(srs_rtmp_t rtmp);
/**
* parse the dts and pts by time in header and data in tag,
* or to parse the RTMP packet by srs_read_packet().
* or to parse the RTMP packet by srs_rtmp_read_packet().
*
* @param time, the timestamp of tag, read by srs_flv_read_tag_header().
* @param type, the type of tag, read by srs_flv_read_tag_header().

@ -129,7 +129,7 @@ file
..\utest\srs_utest_reload.cpp,
research readonly separator,
..\..\research\librtmp\srs_audio_raw_publish.c,
..\..\research\librtmp\srs_bandwidth_check.c,
..\..\research\librtmp\srs_rtmp_bandwidth_check.c,
..\..\research\librtmp\srs_detect_rtmp.c,
..\..\research\librtmp\srs_flv_injecter.c,
..\..\research\librtmp\srs_flv_parser.c,

Loading…
Cancel
Save