1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-12 19:31:53 +00:00

add dvr framework

This commit is contained in:
winlin 2014-04-16 09:28:02 +08:00
parent 96115ac4f7
commit fd0002e499
6 changed files with 63 additions and 8 deletions

2
trunk/configure vendored
View file

@ -440,7 +440,7 @@ MODULE_FILES=("srs_app_server" "srs_app_conn" "srs_app_rtmp_conn" "srs_app_socke
"srs_app_http" "srs_app_thread" "srs_app_bandwidth" "srs_app_st" "srs_app_log"
"srs_app_config" "srs_app_pithy_print" "srs_app_reload" "srs_app_http_api"
"srs_app_http_conn" "srs_app_http_hooks" "srs_app_json" "srs_app_ingest"
"srs_app_ffmpeg" "srs_app_utility" "srs_app_flv")
"srs_app_ffmpeg" "srs_app_utility" "srs_app_dvr")
APP_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}"
#

View file

@ -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.
*/
#include <srs_app_flv.hpp>
#include <srs_app_dvr.hpp>
#ifdef SRS_AUTO_DVR

View file

@ -21,11 +21,11 @@ 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.
*/
#ifndef SRS_APP_FLV_HPP
#define SRS_APP_FLV_HPP
#ifndef SRS_APP_DVR_HPP
#define SRS_APP_DVR_HPP
/*
#include <srs_app_flv.hpp>
#include <srs_app_dvr.hpp>
*/
#include <srs_core.hpp>

View file

@ -36,6 +36,7 @@ using namespace std;
#include <srs_app_config.hpp>
#include <srs_app_encoder.hpp>
#include <srs_protocol_rtmp.hpp>
#include <srs_app_dvr.hpp>
#define CONST_MAX_JITTER_MS 500
#define DEFAULT_FRAME_TIME_MS 40
@ -431,6 +432,9 @@ SrsSource::SrsSource(SrsRequest* _req)
#ifdef SRS_AUTO_HLS
hls = new SrsHls(this);
#endif
#ifdef SRS_AUTO_DVR
dvr = new SrsDvr(this);
#endif
#ifdef SRS_AUTO_TRANSCODE
encoder = new SrsEncoder();
#endif
@ -477,6 +481,9 @@ SrsSource::~SrsSource()
#ifdef SRS_AUTO_HLS
srs_freep(hls);
#endif
#ifdef SRS_AUTO_DVR
srs_freep(dvr);
#endif
#ifdef SRS_AUTO_TRANSCODE
srs_freep(encoder);
#endif
@ -678,6 +685,13 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata
}
#endif
#ifdef SRS_AUTO_DVR
if (metadata && (ret = dvr->on_meta_data(metadata->metadata)) != ERROR_SUCCESS) {
srs_error("dvr process onMetaData message failed. ret=%d", ret);
return ret;
}
#endif
metadata->metadata->set("server", SrsAmf0Any::str(RTMP_SIG_SRS_KEY" "RTMP_SIG_SRS_VERSION" ("RTMP_SIG_SRS_URL_SHORT")"));
metadata->metadata->set("contributor", SrsAmf0Any::str(RTMP_SIG_SRS_PRIMARY_AUTHROS));
@ -772,6 +786,18 @@ int SrsSource::on_audio(SrsCommonMessage* audio)
}
#endif
#ifdef SRS_AUTO_DVR
if ((ret = dvr->on_audio(msg->copy())) != ERROR_SUCCESS) {
srs_warn("dvr process audio message failed, ignore and disable dvr. ret=%d", ret);
// unpublish, ignore ret.
dvr->on_unpublish();
// ignore.
ret = ERROR_SUCCESS;
}
#endif
// copy to all consumer
if (true) {
std::vector<SrsConsumer*>::iterator it;
@ -849,6 +875,18 @@ int SrsSource::on_video(SrsCommonMessage* video)
}
#endif
#ifdef SRS_AUTO_DVR
if ((ret = dvr->on_video(msg->copy())) != ERROR_SUCCESS) {
srs_warn("dvr process video message failed, ignore and disable dvr. ret=%d", ret);
// unpublish, ignore ret.
dvr->on_unpublish();
// ignore.
ret = ERROR_SUCCESS;
}
#endif
// copy to all consumer
if (true) {
std::vector<SrsConsumer*>::iterator it;
@ -932,6 +970,13 @@ int SrsSource::on_publish(SrsRequest* _req)
return ret;
}
#endif
#ifdef SRS_AUTO_DVR
if ((ret = dvr->on_publish(req)) != ERROR_SUCCESS) {
srs_error("start dvr failed. ret=%d", ret);
return ret;
}
#endif
return ret;
}
@ -945,10 +990,13 @@ void SrsSource::on_unpublish()
encoder->on_unpublish();
#endif
// TODO: HLS should continue previous sequence and stream.
#ifdef SRS_AUTO_HLS
hls->on_unpublish();
#endif
#ifdef SRS_AUTO_DVR
dvr->on_unpublish();
#endif
gop_cache->clear();

View file

@ -46,6 +46,9 @@ class SrsRequest;
#ifdef SRS_AUTO_HLS
class SrsHls;
#endif
#ifdef SRS_AUTO_DVR
class SrsDvr;
#endif
#ifdef SRS_AUTO_TRANSCODE
class SrsEncoder;
#endif
@ -222,6 +225,10 @@ private:
// hls handler.
#ifdef SRS_AUTO_HLS
SrsHls* hls;
#endif
// dvr handler.
#ifdef SRS_AUTO_DVR
SrsDvr* dvr;
#endif
// transcoding handler.
#ifdef SRS_AUTO_TRANSCODE

View file

@ -47,12 +47,12 @@ file
..\app\srs_app_conn.cpp,
..\app\srs_app_config.hpp,
..\app\srs_app_config.cpp,
..\app\srs_app_dvr.hpp,
..\app\srs_app_dvr.cpp,
..\app\srs_app_encoder.hpp,
..\app\srs_app_encoder.cpp,
..\app\srs_app_ffmpeg.hpp,
..\app\srs_app_ffmpeg.cpp,
..\app\srs_app_flv.hpp,
..\app\srs_app_flv.cpp,
..\app\srs_app_forward.hpp,
..\app\srs_app_forward.cpp,
..\app\srs_app_hls.hpp,