正在显示
6 个修改的文件
包含
51 行增加
和
16 行删除
trunk/configure
100755 → 100644
| @@ -114,7 +114,8 @@ MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" | @@ -114,7 +114,8 @@ MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server" | ||
| 114 | "srs_core_autofree" "srs_core_protocol" "srs_core_amf0" | 114 | "srs_core_autofree" "srs_core_protocol" "srs_core_amf0" |
| 115 | "srs_core_stream" "srs_core_source" "srs_core_codec" | 115 | "srs_core_stream" "srs_core_source" "srs_core_codec" |
| 116 | "srs_core_handshake" "srs_core_pithy_print" | 116 | "srs_core_handshake" "srs_core_pithy_print" |
| 117 | - "srs_core_config" "srs_core_refer" "srs_core_reload") | 117 | + "srs_core_config" "srs_core_refer" "srs_core_reload" |
| 118 | + "srs_core_hls") | ||
| 118 | MODULE_DIR="src/core" . auto/modules.sh | 119 | MODULE_DIR="src/core" . auto/modules.sh |
| 119 | CORE_OBJS="${MODULE_OBJS[@]}" | 120 | CORE_OBJS="${MODULE_OBJS[@]}" |
| 120 | 121 |
| @@ -36,6 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -36,6 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 36 | #include <srs_core_pithy_print.hpp> | 36 | #include <srs_core_pithy_print.hpp> |
| 37 | #include <srs_core_config.hpp> | 37 | #include <srs_core_config.hpp> |
| 38 | #include <srs_core_refer.hpp> | 38 | #include <srs_core_refer.hpp> |
| 39 | +#include <srs_core_hls.hpp> | ||
| 39 | 40 | ||
| 40 | #define SRS_PULSE_TIMEOUT_MS 100 | 41 | #define SRS_PULSE_TIMEOUT_MS 100 |
| 41 | #define SRS_SEND_TIMEOUT_MS 5000000L | 42 | #define SRS_SEND_TIMEOUT_MS 5000000L |
| @@ -330,6 +331,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle) | @@ -330,6 +331,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle) | ||
| 330 | 331 | ||
| 331 | SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER); | 332 | SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER); |
| 332 | 333 | ||
| 334 | + SrsHLS* hls = source->get_hls(); | ||
| 333 | while (true) { | 335 | while (true) { |
| 334 | // switch to other st-threads. | 336 | // switch to other st-threads. |
| 335 | st_usleep(0); | 337 | st_usleep(0); |
| @@ -23,3 +23,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -23,3 +23,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 23 | 23 | ||
| 24 | #include <srs_core_hls.hpp> | 24 | #include <srs_core_hls.hpp> |
| 25 | 25 | ||
| 26 | +SrsHLS::SrsHLS() | ||
| 27 | +{ | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +SrsHLS::~SrsHLS() | ||
| 31 | +{ | ||
| 32 | +} | ||
| 33 | + |
| @@ -29,4 +29,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -29,4 +29,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 29 | */ | 29 | */ |
| 30 | #include <srs_core.hpp> | 30 | #include <srs_core.hpp> |
| 31 | 31 | ||
| 32 | +class SrsHLS | ||
| 33 | +{ | ||
| 34 | +public: | ||
| 35 | + SrsHLS(); | ||
| 36 | + virtual ~SrsHLS(); | ||
| 37 | +}; | ||
| 38 | + | ||
| 32 | #endif | 39 | #endif |
| @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 30 | #include <srs_core_autofree.hpp> | 30 | #include <srs_core_autofree.hpp> |
| 31 | #include <srs_core_amf0.hpp> | 31 | #include <srs_core_amf0.hpp> |
| 32 | #include <srs_core_codec.hpp> | 32 | #include <srs_core_codec.hpp> |
| 33 | +#include <srs_core_hls.hpp> | ||
| 33 | 34 | ||
| 34 | #define CONST_MAX_JITTER_MS 500 | 35 | #define CONST_MAX_JITTER_MS 500 |
| 35 | #define DEFAULT_FRAME_TIME_MS 10 | 36 | #define DEFAULT_FRAME_TIME_MS 10 |
| @@ -240,6 +241,7 @@ SrsSource::SrsSource(std::string _stream_url) | @@ -240,6 +241,7 @@ SrsSource::SrsSource(std::string _stream_url) | ||
| 240 | { | 241 | { |
| 241 | stream_url = _stream_url; | 242 | stream_url = _stream_url; |
| 242 | codec = new SrsCodec(); | 243 | codec = new SrsCodec(); |
| 244 | + hls = new SrsHLS(); | ||
| 243 | 245 | ||
| 244 | cache_metadata = cache_sh_video = cache_sh_audio = NULL; | 246 | cache_metadata = cache_sh_video = cache_sh_audio = NULL; |
| 245 | 247 | ||
| @@ -265,13 +267,20 @@ SrsSource::~SrsSource() | @@ -265,13 +267,20 @@ SrsSource::~SrsSource() | ||
| 265 | srs_freep(cache_sh_audio); | 267 | srs_freep(cache_sh_audio); |
| 266 | 268 | ||
| 267 | srs_freep(codec); | 269 | srs_freep(codec); |
| 270 | + srs_freep(hls); | ||
| 271 | +} | ||
| 272 | + | ||
| 273 | +SrsHLS* SrsSource::get_hls() | ||
| 274 | +{ | ||
| 275 | + return hls; | ||
| 268 | } | 276 | } |
| 269 | 277 | ||
| 270 | int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata) | 278 | int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata) |
| 271 | { | 279 | { |
| 272 | int ret = ERROR_SUCCESS; | 280 | int ret = ERROR_SUCCESS; |
| 273 | 281 | ||
| 274 | - metadata->metadata->set("server", new SrsAmf0String( | 282 | + metadata->metadata->set("server", new SrsAmf0String(RTMP_SIG_SRS_KEY)); |
| 283 | + metadata->metadata->set("srs_server", new SrsAmf0String( | ||
| 275 | RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")")); | 284 | RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")")); |
| 276 | 285 | ||
| 277 | SrsAmf0Any* prop = NULL; | 286 | SrsAmf0Any* prop = NULL; |
| @@ -418,6 +427,19 @@ int SrsSource::on_video(SrsCommonMessage* video) | @@ -418,6 +427,19 @@ int SrsSource::on_video(SrsCommonMessage* video) | ||
| 418 | return ret; | 427 | return ret; |
| 419 | } | 428 | } |
| 420 | 429 | ||
| 430 | +void SrsSource::on_unpublish() | ||
| 431 | +{ | ||
| 432 | + clear_gop_cache(); | ||
| 433 | + | ||
| 434 | + srs_freep(cache_metadata); | ||
| 435 | + video_frame_rate = audio_sample_rate = 0; | ||
| 436 | + | ||
| 437 | + srs_freep(cache_sh_video); | ||
| 438 | + srs_freep(cache_sh_audio); | ||
| 439 | + | ||
| 440 | + srs_trace("clear cache/metadata/sequence-headers when unpublish."); | ||
| 441 | +} | ||
| 442 | + | ||
| 421 | int SrsSource::create_consumer(SrsConsumer*& consumer) | 443 | int SrsSource::create_consumer(SrsConsumer*& consumer) |
| 422 | { | 444 | { |
| 423 | int ret = ERROR_SUCCESS; | 445 | int ret = ERROR_SUCCESS; |
| @@ -466,19 +488,6 @@ void SrsSource::on_consumer_destroy(SrsConsumer* consumer) | @@ -466,19 +488,6 @@ void SrsSource::on_consumer_destroy(SrsConsumer* consumer) | ||
| 466 | srs_info("handle consumer destroy success."); | 488 | srs_info("handle consumer destroy success."); |
| 467 | } | 489 | } |
| 468 | 490 | ||
| 469 | -void SrsSource::on_unpublish() | ||
| 470 | -{ | ||
| 471 | - clear_gop_cache(); | ||
| 472 | - | ||
| 473 | - srs_freep(cache_metadata); | ||
| 474 | - video_frame_rate = audio_sample_rate = 0; | ||
| 475 | - | ||
| 476 | - srs_freep(cache_sh_video); | ||
| 477 | - srs_freep(cache_sh_audio); | ||
| 478 | - | ||
| 479 | - srs_trace("clear cache/metadata/sequence-headers when unpublish."); | ||
| 480 | -} | ||
| 481 | - | ||
| 482 | void SrsSource::set_cache(bool enabled) | 491 | void SrsSource::set_cache(bool enabled) |
| 483 | { | 492 | { |
| 484 | enable_gop_cache = enabled; | 493 | enable_gop_cache = enabled; |
| @@ -39,6 +39,7 @@ class SrsSource; | @@ -39,6 +39,7 @@ class SrsSource; | ||
| 39 | class SrsCommonMessage; | 39 | class SrsCommonMessage; |
| 40 | class SrsOnMetaDataPacket; | 40 | class SrsOnMetaDataPacket; |
| 41 | class SrsSharedPtrMessage; | 41 | class SrsSharedPtrMessage; |
| 42 | +class SrsHLS; | ||
| 42 | 43 | ||
| 43 | /** | 44 | /** |
| 44 | * the consumer for SrsSource, that is a play client. | 45 | * the consumer for SrsSource, that is a play client. |
| @@ -106,6 +107,7 @@ public: | @@ -106,6 +107,7 @@ public: | ||
| 106 | */ | 107 | */ |
| 107 | static SrsSource* find(std::string stream_url); | 108 | static SrsSource* find(std::string stream_url); |
| 108 | private: | 109 | private: |
| 110 | + SrsHLS* hls; | ||
| 109 | SrsCodec* codec; | 111 | SrsCodec* codec; |
| 110 | std::string stream_url; | 112 | std::string stream_url; |
| 111 | std::vector<SrsConsumer*> consumers; | 113 | std::vector<SrsConsumer*> consumers; |
| @@ -144,13 +146,19 @@ public: | @@ -144,13 +146,19 @@ public: | ||
| 144 | SrsSource(std::string _stream_url); | 146 | SrsSource(std::string _stream_url); |
| 145 | virtual ~SrsSource(); | 147 | virtual ~SrsSource(); |
| 146 | public: | 148 | public: |
| 149 | + /** | ||
| 150 | + * get the hls handler, which has a long lifecycle | ||
| 151 | + * util the source destroyed. | ||
| 152 | + */ | ||
| 153 | + virtual SrsHLS* get_hls(); | ||
| 154 | +public: | ||
| 147 | virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata); | 155 | virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata); |
| 148 | virtual int on_audio(SrsCommonMessage* audio); | 156 | virtual int on_audio(SrsCommonMessage* audio); |
| 149 | virtual int on_video(SrsCommonMessage* video); | 157 | virtual int on_video(SrsCommonMessage* video); |
| 158 | + virtual void on_unpublish(); | ||
| 150 | public: | 159 | public: |
| 151 | virtual int create_consumer(SrsConsumer*& consumer); | 160 | virtual int create_consumer(SrsConsumer*& consumer); |
| 152 | virtual void on_consumer_destroy(SrsConsumer* consumer); | 161 | virtual void on_consumer_destroy(SrsConsumer* consumer); |
| 153 | - virtual void on_unpublish(); | ||
| 154 | virtual void set_cache(bool enabled); | 162 | virtual void set_cache(bool enabled); |
| 155 | private: | 163 | private: |
| 156 | /** | 164 | /** |
-
请 注册 或 登录 后发表评论