mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 03:41:55 +00:00
dvr use .tmp and rename to .flv when finished.
This commit is contained in:
parent
733ca2475d
commit
435e02db5d
3 changed files with 23 additions and 2 deletions
|
@ -454,7 +454,9 @@ int SrsDvrPlan::flv_open(string stream, string path)
|
|||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if ((ret = fs->open(path)) != ERROR_SUCCESS) {
|
||||
current_flv_path = path;
|
||||
std::string tmp_file = path + ".tmp";
|
||||
if ((ret = fs->open(tmp_file)) != ERROR_SUCCESS) {
|
||||
srs_error("open file stream for file %s failed. ret=%d", path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
@ -487,7 +489,21 @@ int SrsDvrPlan::on_video_msg(SrsSharedPtrMessage* /*video*/)
|
|||
|
||||
int SrsDvrPlan::flv_close()
|
||||
{
|
||||
return fs->close();
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
if ((ret = fs->close()) != ERROR_SUCCESS) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::string tmp_file = current_flv_path + ".tmp";
|
||||
if (rename(tmp_file.c_str(), current_flv_path.c_str()) < 0) {
|
||||
ret = ERROR_SYSTEM_FILE_RENAME;
|
||||
srs_error("rename flv file failed, %s => %s. ret=%d",
|
||||
tmp_file.c_str(), current_flv_path.c_str(), ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int SrsDvrPlan::on_dvr_keyframe()
|
||||
|
|
|
@ -127,6 +127,10 @@ protected:
|
|||
SrsSource* _source;
|
||||
SrsRequest* _req;
|
||||
SrsRtmpJitter* jitter;
|
||||
/**
|
||||
* current flv file path.
|
||||
*/
|
||||
std::string current_flv_path;
|
||||
public:
|
||||
SrsDvrPlan();
|
||||
virtual ~SrsDvrPlan();
|
||||
|
|
|
@ -106,6 +106,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#define ERROR_SYSTEM_FILE_READ 426
|
||||
#define ERROR_SYSTEM_FILE_WRITE 427
|
||||
#define ERROR_SYSTEM_FILE_EOF 428
|
||||
#define ERROR_SYSTEM_FILE_RENAME 429
|
||||
|
||||
// see librtmp.
|
||||
// failed when open ssl create the dh
|
||||
|
|
Loading…
Reference in a new issue