forked from DoubangoTelecom/webrtc2sip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mp_proxyplugin_producer_video.h
executable file
·115 lines (99 loc) · 3.85 KB
/
mp_proxyplugin_producer_video.h
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/* Copyright (C) 2012-2015 Doubango Telecom <http://www.doubango.org>
*
* This file is part of Open Source 'webrtc2sip' project
* <http://code.google.com/p/webrtc2sip/>
*
* 'webrtc2sip' is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 'webrtc2sip' is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with 'webrtc2sip'.
*/
#if !defined(_MEDIAPROXY_PROXYPLUGIN_PRODUCER_VIDEO_H_)
#define _MEDIAPROXY_PROXYPLUGIN_PRODUCER_VIDEO_H_
#include "mp_config.h"
#include "mp_proxyplugin.h"
#include "ProxyProducer.h"
namespace webrtc2sip {
class MPProxyPluginProducerVideoCallback;
//
// MPProxyPluginProducerVideo
//
class MPProxyPluginProducerVideo : public MPProxyPlugin
{
friend class MPProxyPluginProducerVideoCallback;
public:
MPProxyPluginProducerVideo(uint64_t nId, const ProxyVideoProducer* pcProducer);
virtual ~MPProxyPluginProducerVideo();
// Encode then send
int push(const void* pcBuffer, unsigned nBufferSize, unsigned nFrameWidth, unsigned nFrameHeight);
// Send "AS IS"
int sendRaw(const void* pcBuffer, unsigned nSize, unsigned nDuration, bool bMarker){
if(m_bStarted){
return m_pcWrappedProducer ? const_cast<ProxyVideoProducer*>(m_pcWrappedProducer)->sendRaw(pcBuffer, nSize, nDuration, bMarker) : 0;
}
TSK_DEBUG_INFO("Video producer not started yet");
return 0;
}
int sendRaw(const void* pcBuffer, unsigned nSize, const void* pcProtoHdr){
if(m_bStarted){
return m_pcWrappedProducer ? const_cast<ProxyVideoProducer*>(m_pcWrappedProducer)->sendRaw(pcBuffer, nSize, pcProtoHdr) : 0;
}
TSK_DEBUG_INFO("Video producer not started yet");
return 0;
}
bool setActualCameraOutputSize(unsigned nWidth, unsigned nHeight){
return m_pcWrappedProducer ? const_cast<ProxyVideoProducer*>(m_pcWrappedProducer)->setActualCameraOutputSize(nWidth, nHeight) : 0;
}
MP_INLINE int getFps() { return m_nFPS; }
MP_INLINE int getHeight() { return m_nHeight; }
MP_INLINE int getWidth() { return m_nWidth; }
MP_INLINE void setByPassEncoding(bool bByPass){ m_bByPassEncoding = bByPass; }
MP_INLINE bool isByPassEncoding(){ return m_bByPassEncoding; }
private:
int prepareCallback(int nWidth, int nHeight, int nFps);
int startCallback();
int pauseCallback();
int stopCallback();
private:
MPObjectWrapper<MPProxyPluginProducerVideoCallback*> m_oCallback;
const ProxyVideoProducer* m_pcWrappedProducer;
int m_nWidth, m_nHeight, m_nFPS;
bool m_bByPassEncoding;
};
//
// MPProxyPluginProducerVideoCallback
//
class MPProxyPluginProducerVideoCallback : public ProxyVideoProducerCallback, public MPObject {
public:
MPProxyPluginProducerVideoCallback(const MPProxyPluginProducerVideo* pcMPProducer)
: ProxyVideoProducerCallback(), m_pcMPProducer(pcMPProducer){
}
virtual ~MPProxyPluginProducerVideoCallback(){
}
MP_INLINE virtual const char* getObjectId() { return "MPProxyPluginProducerVideoCallback"; }
public: /* Overrides */
virtual int prepare(int width, int height, int fps) {
return const_cast<MPProxyPluginProducerVideo*>(m_pcMPProducer)->prepareCallback(width, height, fps);
}
virtual int start() {
return const_cast<MPProxyPluginProducerVideo*>(m_pcMPProducer)->startCallback();
}
virtual int pause() {
return const_cast<MPProxyPluginProducerVideo*>(m_pcMPProducer)->pauseCallback();
}
virtual int stop() {
return const_cast<MPProxyPluginProducerVideo*>(m_pcMPProducer)->stopCallback();
}
private:
const MPProxyPluginProducerVideo* m_pcMPProducer;
};
} // namespace
#endif /* _MEDIAPROXY_PROXYPLUGIN_PRODUCER_VIDEO_H_ */