正在显示
6 个修改的文件
包含
109 行增加
和
7 行删除
| @@ -73,6 +73,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -73,6 +73,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 73 | #endif | 73 | #endif |
| 74 | 74 | ||
| 75 | // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | 75 | // for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 |
| 76 | +#if defined(_WIN32) | ||
| 77 | + #include <windows.h> | ||
| 78 | +#endif | ||
| 79 | + | ||
| 80 | +// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 76 | #ifndef _WIN32 | 81 | #ifndef _WIN32 |
| 77 | #include <inttypes.h> | 82 | #include <inttypes.h> |
| 78 | #endif | 83 | #endif |
| @@ -24,11 +24,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -24,11 +24,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 24 | #ifndef SRS_WIN_PORTING_H | 24 | #ifndef SRS_WIN_PORTING_H |
| 25 | #define SRS_WIN_PORTING_H | 25 | #define SRS_WIN_PORTING_H |
| 26 | 26 | ||
| 27 | -// for srs-librtmp, @see https://github.com/winlinvip/simple-rtmp-server/issues/213 | ||
| 28 | -#if defined(_WIN32) | ||
| 29 | - #include <windows.h> | ||
| 30 | -#endif | ||
| 31 | - | ||
| 32 | /** | 27 | /** |
| 33 | * for linux like, | 28 | * for linux like, |
| 34 | * for example, not on windows or it's cygwin. | 29 | * for example, not on windows or it's cygwin. |
| @@ -30,6 +30,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,6 +30,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | 30 | ||
| 31 | #include <sys/types.h> | 31 | #include <sys/types.h> |
| 32 | 32 | ||
| 33 | +#ifdef _WIN32 | ||
| 34 | + typedef long int int64_t; | ||
| 35 | + typedef unsigned int u_int32_t; | ||
| 36 | + typedef int int32_t; | ||
| 37 | +#endif | ||
| 33 | 38 | ||
| 34 | /** | 39 | /** |
| 35 | * srs-librtmp is a librtmp like library, | 40 | * srs-librtmp is a librtmp like library, |
trunk/winbuild/srs_play.cpp
0 → 100644
| 1 | +/* | ||
| 2 | +The MIT License (MIT) | ||
| 3 | + | ||
| 4 | +Copyright (c) 2013-2014 winlin | ||
| 5 | + | ||
| 6 | +Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
| 7 | +this software and associated documentation files (the "Software"), to deal in | ||
| 8 | +the Software without restriction, including without limitation the rights to | ||
| 9 | +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
| 10 | +the Software, and to permit persons to whom the Software is furnished to do so, | ||
| 11 | +subject to the following conditions: | ||
| 12 | + | ||
| 13 | +The above copyright notice and this permission notice shall be included in all | ||
| 14 | +copies or substantial portions of the Software. | ||
| 15 | + | ||
| 16 | +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 17 | +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
| 18 | +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
| 19 | +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
| 20 | +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 21 | +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 22 | +*/ | ||
| 23 | +/** | ||
| 24 | +gcc srs_play.c ../../objs/lib/srs_librtmp.a -g -O0 -lstdc++ -o srs_play | ||
| 25 | +*/ | ||
| 26 | + | ||
| 27 | +#include <stdio.h> | ||
| 28 | +#include <stdlib.h> | ||
| 29 | + | ||
| 30 | +#include "srs_librtmp.hpp" | ||
| 31 | + | ||
| 32 | +int main(int argc, char** argv) | ||
| 33 | +{ | ||
| 34 | + printf("suck rtmp stream like rtmpdump\n"); | ||
| 35 | + printf("srs(simple-rtmp-server) client librtmp library.\n"); | ||
| 36 | + printf("version: %d.%d.%d\n", srs_version_major(), srs_version_minor(), srs_version_revision()); | ||
| 37 | + | ||
| 38 | + if (argc <= 1) { | ||
| 39 | + printf("Usage: %s <rtmp_url>\n" | ||
| 40 | + " rtmp_url RTMP stream url to play\n" | ||
| 41 | + "For example:\n" | ||
| 42 | + " %s rtmp://127.0.0.1:1935/live/livestream\n", | ||
| 43 | + argv[0], argv[0]); | ||
| 44 | + exit(-1); | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + srs_human_trace("rtmp url: %s", argv[1]); | ||
| 48 | + srs_rtmp_t rtmp = srs_rtmp_create(argv[1]); | ||
| 49 | + | ||
| 50 | + if (srs_rtmp_handshake(rtmp) != 0) { | ||
| 51 | + srs_human_trace("simple handshake failed."); | ||
| 52 | + goto rtmp_destroy; | ||
| 53 | + } | ||
| 54 | + srs_human_trace("simple handshake success"); | ||
| 55 | + | ||
| 56 | + if (srs_rtmp_connect_app(rtmp) != 0) { | ||
| 57 | + srs_human_trace("connect vhost/app failed."); | ||
| 58 | + goto rtmp_destroy; | ||
| 59 | + } | ||
| 60 | + srs_human_trace("connect vhost/app success"); | ||
| 61 | + | ||
| 62 | + if (srs_rtmp_play_stream(rtmp) != 0) { | ||
| 63 | + srs_human_trace("play stream failed."); | ||
| 64 | + goto rtmp_destroy; | ||
| 65 | + } | ||
| 66 | + srs_human_trace("play stream success"); | ||
| 67 | + | ||
| 68 | + for (;;) { | ||
| 69 | + int size; | ||
| 70 | + char type; | ||
| 71 | + char* data; | ||
| 72 | + u_int32_t timestamp; | ||
| 73 | + | ||
| 74 | + if (srs_rtmp_read_packet(rtmp, &type, ×tamp, &data, &size) != 0) { | ||
| 75 | + goto rtmp_destroy; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + if (srs_human_print_rtmp_packet(type, timestamp, data, size) != 0) { | ||
| 79 | + goto rtmp_destroy; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + free(data); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | +rtmp_destroy: | ||
| 86 | + srs_rtmp_destroy(rtmp); | ||
| 87 | + | ||
| 88 | + return 0; | ||
| 89 | +} |
trunk/winbuild/srs_play.vcxproj
100644 → 100755
| @@ -77,7 +77,10 @@ | @@ -77,7 +77,10 @@ | ||
| 77 | </Link> | 77 | </Link> |
| 78 | </ItemDefinitionGroup> | 78 | </ItemDefinitionGroup> |
| 79 | <ItemGroup> | 79 | <ItemGroup> |
| 80 | - <ClCompile Include="srs_play.c" /> | 80 | + <ClCompile Include="srs_play.cpp" /> |
| 81 | + </ItemGroup> | ||
| 82 | + <ItemGroup> | ||
| 83 | + <ClInclude Include="srs_auto_headers.hpp" /> | ||
| 81 | </ItemGroup> | 84 | </ItemGroup> |
| 82 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | 85 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> |
| 83 | <ImportGroup Label="ExtensionTargets"> | 86 | <ImportGroup Label="ExtensionTargets"> |
trunk/winbuild/srs_play.vcxproj.filters
100644 → 100755
| @@ -15,7 +15,12 @@ | @@ -15,7 +15,12 @@ | ||
| 15 | </Filter> | 15 | </Filter> |
| 16 | </ItemGroup> | 16 | </ItemGroup> |
| 17 | <ItemGroup> | 17 | <ItemGroup> |
| 18 | - <ClCompile Include="srs_play.c"> | 18 | + <ClInclude Include="srs_auto_headers.hpp"> |
| 19 | + <Filter>Header Files</Filter> | ||
| 20 | + </ClInclude> | ||
| 21 | + </ItemGroup> | ||
| 22 | + <ItemGroup> | ||
| 23 | + <ClCompile Include="srs_play.cpp"> | ||
| 19 | <Filter>Source Files</Filter> | 24 | <Filter>Source Files</Filter> |
| 20 | </ClCompile> | 25 | </ClCompile> |
| 21 | </ItemGroup> | 26 | </ItemGroup> |
-
请 注册 或 登录 后发表评论