-
Notifications
You must be signed in to change notification settings - Fork 351
/
Copy pathvideopacketsource_h
86 lines (63 loc) · 2.32 KB
/
videopacketsource_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
///
//
// LibSourcey
// Copyright (c) 2005, Sourcey <https://sourcey.com>
//
// SPDX-License-Identifier: LGPL-2.1+
//
/// @addtogroup webrtc
/// @{
#ifndef SCY_WebRTC_VideoPacketSource_H
#define SCY_WebRTC_VideoPacketSource_H
#include "scy/base.h"
#include "scy/packetsignal.h"
#ifdef HAVE_FFMPEG
#include "scy/av/packet.h"
#include "media/base/videocapturer.h"
namespace scy {
namespace wrtc {
/// VideoPacketSource implements a simple `cricket::VideoCapturer` that
/// gets decoded remote video frames from a local media channel.
/// It's used as the remote video source's `VideoCapturer` so that the remote
/// video can be used as a `cricket::VideoCapturer` and in that way a remote
/// video stream can implement the `MediaStreamSourceInterface`.
class VideoPacketSource : public cricket::VideoCapturer
{
public:
VideoPacketSource(int width, int height, int fps, uint32_t fourcc);
VideoPacketSource(const cricket::VideoFormat& captureFormat);
virtual ~VideoPacketSource();
/// Set the source `av::VideoPacket` emitter.
/// The pointer is not managed by this class.
void setPacketSource(PacketSignal* source);
/// Callback that fired when an `av::PlanarVideoPacket`
/// is ready for processing.
void onVideoCaptured(av::PlanarVideoPacket& packet);
/// cricket::VideoCapturer implementation.
virtual cricket::CaptureState Start(const cricket::VideoFormat& capture_format) override;
virtual void Stop() override;
virtual bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) override;
virtual bool GetBestCaptureFormat(const cricket::VideoFormat& desired,
cricket::VideoFormat* best_format) override;
virtual bool IsRunning() override;
virtual bool IsScreencast() const override;
protected:
cricket::VideoFormat _captureFormat;
webrtc::VideoRotation _rotation;
int64_t _timestampOffset;
int64_t _nextTimestamp;
PacketSignal* _source;
};
// class VideoPacketSourceFactory : public cricket::VideoDeviceCapturerFactory {
// public:
// VideoPacketSourceFactory() {}
// virtual ~VideoPacketSourceFactory() {}
//
// virtual cricket::VideoCapturer* Create(const cricket::Device& device) {
// return new VideoPacketSource(device.name);
// }
// };
} } // namespace scy::wrtc
#endif // HAVE_FFMPEG
#endif
/// @\}