派生自 development/c++

xuxiuxi
2019-03-08 5bf0020b189b2bc8c64737c2af4ea77c3e8f5612
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include "PushStreamAppPipeController.h"
#include <basic/util/app/AppPreference.hpp>
#include <basic/util/app/AppUtil.h>
//#include <sstream>
#include <algorithm>
#include <basic/util/app/AppConfig.h>
 
PushStreamAppPipeController::PushStreamAppPipeController(std::string &chanPubID, int fps,
                                                         int streamTransType,
                                                         int gpuIdx, RtspAnalysManager *manager) :
    videoCaptureElement(chanPubID, fps, streamTransType, gpuIdx, manager),
    index(chanPubID),
    videoPublishElement(nullptr) {
 
    string path = appConfig.getStringProperty("srsAddr") + "cam" + chanPubID + ".flv";
    cv::Size size_(appPref.getIntData("pulish.width"), appPref.getIntData("pulish.height"));
    int gupIdx = appPref.getLongData("gpu.index");
    videoPublishElement = new ffmpeg::VideoPublishElement(path, size_, "flv", 25, gupIdx);
    if (appPref.getIntData("pulish.width") < 0 || appPref.getIntData("pulish.height") < 0) {
        ERR("pulish.width:  " << appPref.getIntData("pulish.width") << "  Height: "
                              << appPref.getIntData("pulish.height"));
    }
    videoCaptureElement.registerConnector([&] {
        //if(!videoPublishElement.isBusy()){
        videoPublishElement->setImage(videoCaptureElement.getImage());
        //videoPublishElement.submit();
        //}
    });
 
    registerElement(videoCaptureElement);
    registerElement(*videoPublishElement);
 
//    videoCaptureElement.setOutPutInterval(3);
}
 
std::string PushStreamAppPipeController::getRtmp() {
    std::string ret = videoPublishElement->getPath();
    size_t pos = ret.find(".flv");
    ret = ret.substr(0, pos);
    INFO(ret);
    return ret;
}
 
void PushStreamAppPipeController::SaveVideo(const std::string &strImageName) {
    videoCaptureElement.SaveVideo(strImageName);
}
 
void PushStreamAppPipeController::SetVideoMinMaxSeconds(const int minSeconds, const int maxSeconds) {
    videoCaptureElement.SetVideoMinMaxSeconds(minSeconds, maxSeconds);
}