diff --git a/trunk/src/core/srs_core.hpp b/trunk/src/core/srs_core.hpp index bffedbbb3..785d12d50 100644 --- a/trunk/src/core/srs_core.hpp +++ b/trunk/src/core/srs_core.hpp @@ -72,6 +72,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define __STDC_FORMAT_MACROS #endif +// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 +#if defined(_WIN32) + #include +#endif + // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 #ifndef _WIN32 #include diff --git a/trunk/src/core/srs_platform.hpp b/trunk/src/core/srs_platform.hpp index 1bd61d124..2604a0e88 100644 --- a/trunk/src/core/srs_platform.hpp +++ b/trunk/src/core/srs_platform.hpp @@ -24,11 +24,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef SRS_WIN_PORTING_H #define SRS_WIN_PORTING_H -// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 -#if defined(_WIN32) - #include -#endif - /** * for linux like, * for example, not on windows or it's cygwin. diff --git a/trunk/src/libs/srs_librtmp.hpp b/trunk/src/libs/srs_librtmp.hpp index fb39ddd32..206a9d9c4 100644 --- a/trunk/src/libs/srs_librtmp.hpp +++ b/trunk/src/libs/srs_librtmp.hpp @@ -30,6 +30,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include +#ifdef _WIN32 + typedef long int int64_t; + typedef unsigned int u_int32_t; + typedef int int32_t; +#endif /** * srs-librtmp is a librtmp like library, diff --git a/trunk/winbuild/srs_play.cpp b/trunk/winbuild/srs_play.cpp new file mode 100644 index 000000000..2891e3a3e --- /dev/null +++ b/trunk/winbuild/srs_play.cpp @@ -0,0 +1,89 @@ +/* +The MIT License (MIT) + +Copyright (c) 2013-2014 winlin + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +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_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play +*/ + +#include +#include + +#include "srs_librtmp.hpp" + +int main(int argc, char** argv) +{ + printf("suck rtmp stream like rtmpdump\n"); + printf("srs(simple-rtmp-server) client librtmp library.\n"); + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); + + if (argc <= 1) { + printf("Usage: %s \n" + " rtmp_url RTMP stream url to play\n" + "For example:\n" + " %s rtmp://127.0.0.1:1935/live/livestream\n", + argv[0], argv[0]); + exit(-1); + } + + srs_human_trace("rtmp url: %s", argv[1]); + srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); + + if (srs_rtmp_handshake(rtmp) != 0) { + srs_human_trace("simple handshake failed."); + goto rtmp_destroy; + } + srs_human_trace("simple handshake success"); + + 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_rtmp_play_stream(rtmp) != 0) { + srs_human_trace("play stream failed."); + goto rtmp_destroy; + } + srs_human_trace("play stream success"); + + for (;;) { + int size; + char type; + char* data; + u_int32_t timestamp; + + if (srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { + goto rtmp_destroy; + } + + if (srs_human_print_rtmp_packet(type, timestamp, data, size) != 0) { + goto rtmp_destroy; + } + + free(data); + } + +rtmp_destroy: + srs_rtmp_destroy(rtmp); + + return 0; +} diff --git a/trunk/winbuild/srs_play.vcxproj b/trunk/winbuild/srs_play.vcxproj old mode 100644 new mode 100755 index 0480153df..22d653d2b --- a/trunk/winbuild/srs_play.vcxproj +++ b/trunk/winbuild/srs_play.vcxproj @@ -1,85 +1,88 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {5149B9A9-5085-4A10-AD6F-23FBE6854390} - Win32Proj - srs_play - - - - Application - true - Unicode - - - Application - false - true - Unicode - - - - - - - - - - - - - true - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) - ..\src\core;..\src\libs;%(AdditionalIncludeDirectories) - - - Console - true - srs-librtmp.lib;%(AdditionalDependencies) - ./debug;%(AdditionalLibraryDirectories) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - - - - + + + + + Debug + Win32 + + + Release + Win32 + + + + {5149B9A9-5085-4A10-AD6F-23FBE6854390} + Win32Proj + srs_play + + + + Application + true + Unicode + + + Application + false + true + Unicode + + + + + + + + + + + + + true + + + false + + + + + + Level3 + Disabled + WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + ..\src\core;..\src\libs;%(AdditionalIncludeDirectories) + + + Console + true + srs-librtmp.lib;%(AdditionalDependencies) + ./debug;%(AdditionalLibraryDirectories) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + + + Console + true + true + true + + + + + + + + + + + + \ No newline at end of file diff --git a/trunk/winbuild/srs_play.vcxproj.filters b/trunk/winbuild/srs_play.vcxproj.filters old mode 100644 new mode 100755 index f6123616d..c66bb8bc0 --- a/trunk/winbuild/srs_play.vcxproj.filters +++ b/trunk/winbuild/srs_play.vcxproj.filters @@ -1,22 +1,27 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hpp;hxx;hm;inl;inc;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + Header Files + + + + + Source Files + + + \ No newline at end of file