-
Notifications
You must be signed in to change notification settings - Fork 165
/
mp_proxyplugin_consumer_video.h
executable file
·108 lines (96 loc) · 3.89 KB
/
mp_proxyplugin_consumer_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
/* 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_CONSUMER_VIDEO_H_)
#define _MEDIAPROXY_PROXYPLUGIN_CONSUMER_VIDEO_H_
#include "mp_config.h"
#include "mp_proxyplugin.h"
#include "mp_proxyplugin_producer_video.h"
#include "ProxyConsumer.h"
namespace webrtc2sip {
class MPProxyPluginConsumerVideoCallback;
class MPProxyPluginConsumerVideo : public MPProxyPlugin
{
friend class MPProxyPluginConsumerVideoCallback;
public:
MPProxyPluginConsumerVideo(uint64_t nId, const ProxyVideoConsumer* pcConsumer);
virtual ~MPProxyPluginConsumerVideo();
MP_INLINE virtual const char* getObjectId() { return "MPProxyPluginConsumerVideo"; }
public:
MP_INLINE void setProducerOpposite(MPObjectWrapper<MPProxyPluginProducerVideo*> oProducer){
m_oProducerOpposite = oProducer;
}
MP_INLINE bool setDisplaySize(int nWidth, int nHeight){
return m_pcWrappedConsumer ? const_cast<ProxyVideoConsumer*>(m_pcWrappedConsumer)->setDisplaySize(nWidth, nHeight) : false;
}
MP_INLINE bool reset(){
return m_pcWrappedConsumer ? const_cast<ProxyVideoConsumer*>(m_pcWrappedConsumer)->reset() : false;
}
MP_INLINE int getFps() { return m_nFPS; }
MP_INLINE int getHeight() { return m_nHeight; }
MP_INLINE int getWidth() { return m_nWidth; }
MP_INLINE uint64_t getLastRTPPacketTime() { return m_nLastRTPPacketTime; }
MP_INLINE void setByPassDecoding(bool bByPass){ m_bByPassDecoding = bByPass; }
MP_INLINE bool isByPassDecoding(){ return m_bByPassDecoding; }
private:
int prepareCallback(int nWidth, int nHeight, int nFps);
int startCallback();
int consumeCallback(const ProxyVideoFrame* frame);
int pauseCallback();
int stopCallback();
private:
MPObjectWrapper<MPProxyPluginConsumerVideoCallback*> m_oCallback;
// "Left" producer if consumer is on the "right" side and "Right" otherwise
MPObjectWrapper<MPProxyPluginProducerVideo*> m_oProducerOpposite;
const ProxyVideoConsumer* m_pcWrappedConsumer;
int m_nWidth, m_nHeight, m_nFPS;
uint64_t m_nLastRTPPacketTime;
bool m_bByPassDecoding;
};
//
// MPProxyPluginConsumerVideoCallback
//
class MPProxyPluginConsumerVideoCallback : public ProxyVideoConsumerCallback, public MPObject {
public:
MPProxyPluginConsumerVideoCallback(const MPProxyPluginConsumerVideo* pcConsumer)
: ProxyVideoConsumerCallback(), m_pcConsumer(pcConsumer){
}
virtual ~MPProxyPluginConsumerVideoCallback(){
}
MP_INLINE virtual const char* getObjectId() { return "MPProxyPluginConsumerVideoCallback"; }
public: /* Overrides */
virtual int prepare(int width, int height, int fps) {
return const_cast<MPProxyPluginConsumerVideo*>(m_pcConsumer)->prepareCallback(width, height, fps);
}
virtual int start() {
return const_cast<MPProxyPluginConsumerVideo*>(m_pcConsumer)->startCallback();
}
virtual int consume(const ProxyVideoFrame* frame) {
return const_cast<MPProxyPluginConsumerVideo*>(m_pcConsumer)->consumeCallback(frame);
}
virtual int pause() {
return const_cast<MPProxyPluginConsumerVideo*>(m_pcConsumer)->pauseCallback();
}
virtual int stop() {
return const_cast<MPProxyPluginConsumerVideo*>(m_pcConsumer)->stopCallback();
}
private:
const MPProxyPluginConsumerVideo* m_pcConsumer;
};
} // namespace
#endif /* _MEDIAPROXY_PROXYPLUGIN_CONSUMER_VIDEO_H_ */