1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-02-13 03:41:55 +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_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_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_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_INCS="src/app"; MODULE_DIR=${APP_INCS} . auto/modules.sh
APP_OBJS="${MODULE_OBJS[@]}" 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. 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 #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. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
#ifndef SRS_APP_FLV_HPP #ifndef SRS_APP_DVR_HPP
#define SRS_APP_FLV_HPP #define SRS_APP_DVR_HPP
/* /*
#include <srs_app_flv.hpp> #include <srs_app_dvr.hpp>
*/ */
#include <srs_core.hpp> #include <srs_core.hpp>

View file

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

View file

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

View file

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