PrivMX Endpoint v2.7.0
Loading...
Searching...
No Matches
OnTrackInterface.hpp
1#ifndef _PRIVMXLIB_ENDPOINT_STREAM_ONTRACKINTERFACE_HPP
2#define _PRIVMXLIB_ENDPOINT_STREAM_ONTRACKINTERFACE_HPP
3
4#include <string>
5#include <optional>
6#include "privmx/endpoint/stream/webrtc/Types.hpp"
7#include <privmx/endpoint/stream/Types.hpp>
8
9namespace privmx {
10namespace endpoint {
11namespace stream {
12
13enum TrackAction {
14 REMOVED,
15 ADDED
16};
17enum DataType {
18 VIDEO,
19 AUDIO,
20 PLAIN
21};
22struct Track {
23 DataType kind;
24 std::vector<std::string> streamIds;
25 std::string trackId;
26 bool muted;
27 std::function<void(bool)> updateMute;
28};
29struct TrackEvent {
30 std::string id;
31 std::optional<Track> track;
32 Stream stream;
33};
34struct Data {
35 Data(DataType _type, const std::vector<std::string> _streamIds, const std::string _track)
36 : type(_type), streamIds(_streamIds), track(_track) {}
37 virtual ~Data() = default;
38 DataType type;
39 const std::vector<std::string> streamIds;
40 const std::string track;
41};
42
43class Frame {
44public:
45 virtual int ConvertToRGBA(uint8_t* dst_argb, int dst_stride_argb, int dest_width, int dest_height) = 0;
46};
47
48struct VideoData : public Data {
49 VideoData(DataType _type, const std::vector<std::string>& _streamIds, const std::string _track, const int64_t _w, const int64_t _h, std::shared_ptr<Frame> _frameData )
50 : Data(_type, _streamIds, _track), w(_w), h(_h), frameData(_frameData) {}
51 const int64_t w;
52 const int64_t h;
53 std::shared_ptr<Frame> frameData;
54};
55struct AudioData : public Data {
56 AudioData(DataType _type, const std::vector<std::string>& _streamIds, const std::string _track, const void* _audio_data, int _bits_per_sample, int _sample_rate, size_t _number_of_channels, size_t _number_of_frames)
57 : Data(_type, _streamIds, _track), audio_data(_audio_data), bits_per_sample(_bits_per_sample), sample_rate(_sample_rate), number_of_channels(_number_of_channels), number_of_frames(_number_of_frames) {}
58 const void* audio_data;
59 int bits_per_sample;
60 int sample_rate;
61 size_t number_of_channels;
62 size_t number_of_frames;
63};
64struct PlainData : public Data {
65
66};
67
69public:
70 virtual void OnRemoteTrack(Track tack, TrackAction action) = 0;
71 virtual void OnData(std::shared_ptr<Data> data) = 0;
72protected:
73 virtual ~OnTrackInterface() = default;
74};
75
76} // namespace stream
77} // namespace endpoint
78} // namespace privmx
79
80#endif // _PRIVMXLIB_ENDPOINT_STREAM_ONTRACKINTERFACE_HPP
Definition OnTrackInterface.hpp:43
Definition OnTrackInterface.hpp:68
Definition OnTrackInterface.hpp:64
Definition Types.hpp:60
Definition OnTrackInterface.hpp:29
Definition OnTrackInterface.hpp:22