winlin

change metadata. add hls class.

... ... @@ -114,7 +114,8 @@ MODULE_FILES=("srs_core" "srs_core_log" "srs_core_server"
"srs_core_autofree" "srs_core_protocol" "srs_core_amf0"
"srs_core_stream" "srs_core_source" "srs_core_codec"
"srs_core_handshake" "srs_core_pithy_print"
"srs_core_config" "srs_core_refer" "srs_core_reload")
"srs_core_config" "srs_core_refer" "srs_core_reload"
"srs_core_hls")
MODULE_DIR="src/core" . auto/modules.sh
CORE_OBJS="${MODULE_OBJS[@]}"
... ...
... ... @@ -36,6 +36,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_pithy_print.hpp>
#include <srs_core_config.hpp>
#include <srs_core_refer.hpp>
#include <srs_core_hls.hpp>
#define SRS_PULSE_TIMEOUT_MS 100
#define SRS_SEND_TIMEOUT_MS 5000000L
... ... @@ -330,6 +331,7 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
SrsPithyPrint pithy_print(SRS_STAGE_PUBLISH_USER);
SrsHLS* hls = source->get_hls();
while (true) {
// switch to other st-threads.
st_usleep(0);
... ...
... ... @@ -23,3 +23,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_hls.hpp>
SrsHLS::SrsHLS()
{
}
SrsHLS::~SrsHLS()
{
}
... ...
... ... @@ -29,4 +29,11 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include <srs_core.hpp>
class SrsHLS
{
public:
SrsHLS();
virtual ~SrsHLS();
};
#endif
\ No newline at end of file
... ...
... ... @@ -30,6 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_core_autofree.hpp>
#include <srs_core_amf0.hpp>
#include <srs_core_codec.hpp>
#include <srs_core_hls.hpp>
#define CONST_MAX_JITTER_MS 500
#define DEFAULT_FRAME_TIME_MS 10
... ... @@ -240,6 +241,7 @@ SrsSource::SrsSource(std::string _stream_url)
{
stream_url = _stream_url;
codec = new SrsCodec();
hls = new SrsHLS();
cache_metadata = cache_sh_video = cache_sh_audio = NULL;
... ... @@ -265,13 +267,20 @@ SrsSource::~SrsSource()
srs_freep(cache_sh_audio);
srs_freep(codec);
srs_freep(hls);
}
SrsHLS* SrsSource::get_hls()
{
return hls;
}
int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata)
{
int ret = ERROR_SUCCESS;
metadata->metadata->set("server", new SrsAmf0String(
metadata->metadata->set("server", new SrsAmf0String(RTMP_SIG_SRS_KEY));
metadata->metadata->set("srs_server", new SrsAmf0String(
RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
SrsAmf0Any* prop = NULL;
... ... @@ -418,6 +427,19 @@ int SrsSource::on_video(SrsCommonMessage* video)
return ret;
}
void SrsSource::on_unpublish()
{
clear_gop_cache();
srs_freep(cache_metadata);
video_frame_rate = audio_sample_rate = 0;
srs_freep(cache_sh_video);
srs_freep(cache_sh_audio);
srs_trace("clear cache/metadata/sequence-headers when unpublish.");
}
int SrsSource::create_consumer(SrsConsumer*& consumer)
{
int ret = ERROR_SUCCESS;
... ... @@ -466,19 +488,6 @@ void SrsSource::on_consumer_destroy(SrsConsumer* consumer)
srs_info("handle consumer destroy success.");
}
void SrsSource::on_unpublish()
{
clear_gop_cache();
srs_freep(cache_metadata);
video_frame_rate = audio_sample_rate = 0;
srs_freep(cache_sh_video);
srs_freep(cache_sh_audio);
srs_trace("clear cache/metadata/sequence-headers when unpublish.");
}
void SrsSource::set_cache(bool enabled)
{
enable_gop_cache = enabled;
... ...
... ... @@ -39,6 +39,7 @@ class SrsSource;
class SrsCommonMessage;
class SrsOnMetaDataPacket;
class SrsSharedPtrMessage;
class SrsHLS;
/**
* the consumer for SrsSource, that is a play client.
... ... @@ -106,6 +107,7 @@ public:
*/
static SrsSource* find(std::string stream_url);
private:
SrsHLS* hls;
SrsCodec* codec;
std::string stream_url;
std::vector<SrsConsumer*> consumers;
... ... @@ -144,13 +146,19 @@ public:
SrsSource(std::string _stream_url);
virtual ~SrsSource();
public:
/**
* get the hls handler, which has a long lifecycle
* util the source destroyed.
*/
virtual SrsHLS* get_hls();
public:
virtual int on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata);
virtual int on_audio(SrsCommonMessage* audio);
virtual int on_video(SrsCommonMessage* video);
virtual void on_unpublish();
public:
virtual int create_consumer(SrsConsumer*& consumer);
virtual void on_consumer_destroy(SrsConsumer* consumer);
virtual void on_unpublish();
virtual void set_cache(bool enabled);
private:
/**
... ...