-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReStreamer.h
More file actions
70 lines (53 loc) · 1.4 KB
/
ReStreamer.h
File metadata and controls
70 lines (53 loc) · 1.4 KB
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
#pragma once
#include <memory>
#include <string>
#include <functional>
#include <CxxPtr/GstPtr.h>
class ReStreamer
{
public:
enum class EosReason {
Disconnect,
RtspSourceError,
RtmpTargetError,
OtherError,
};
typedef std::function<void (EosReason reason)> EosCallback;
ReStreamer(
const std::string& sourceUrl,
const std::string& targetUrl,
const EosCallback& onEos);
~ReStreamer();
const std::string& sourceUrl() const { return _sourceUrl; };
void start() noexcept;
private:
void setState(GstState) noexcept;
void pause() noexcept;
void play() noexcept;
void stop() noexcept;
gboolean onBusMessage(GstMessage*);
void unknownType(
GstElement* decodebin,
GstPad*,
GstCaps*);
void srcPadAdded(GstElement* decodebin, GstPad*);
void noMorePads(GstElement* decodebin);
static void postEos(
GstElement* rtcbin,
gboolean error);
void onEos(EosReason);
private:
EosCallback _onEos;
const std::string _sourceUrl;
const std::string _targetUrl;
GType _rtspSrcType = 0;
GType _rtmpSinkType = 0;
GstElementPtr _pipelinePtr;
GstElementPtr _flvMuxPtr;
GstPadPtr _flvVideoSinkPad;
GstPadPtr _flvAudioSinkPad;
GstCapsPtr _h264CapsPtr;
GstCapsPtr _audioRawCapsPtr;
bool _videoLinked = false;
bool _audioLinked = false;
};