| #include <stdint.h> |
| 6 | #include "../StaticThreads.h" |
| 7 |
| 8 | namespace tgcalls { |
| 9 |
| 10 | class StreamingMediaContextPrivate; |
| 11 |
| 12 | class StreamingMediaContext { |
| 13 | public: |
| 14 | struct VideoChannel { |
| 15 | VideoChannelDescription::Quality quality = VideoChannelDescription::Quality::Thumbnail; |
| 16 | std::string endpoint; |
| 17 |
| 18 | VideoChannel(VideoChannelDescription::Quality quality_, std::string endpoint_) : |
| 19 | quality(quality_), |
| 20 | endpoint(endpoint_) { |
| 21 | } |
| 22 | }; |
| 23 |
| 24 | public: |
| 25 | struct StreamingMediaContextArguments { |
| 26 | std::shared_ptr<Threads> threads; |
| 27 | bool isUnifiedBroadcast = false; |
| 28 | std::function<std::shared_ptr<BroadcastPartTask>(std::function<void(int64_t)>)> requestCurrentTime; |
| 29 | std::function<std::shared_ptr<BroadcastPartTask>(std::shared_ptr<PlatformContext>, int64_t, int64_t, std::function<void(BroadcastPart &&)>)> requestAudioBroadcastPart; |
| 30 | std::function<std::shared_ptr<BroadcastPartTask>(std::shared_ptr<PlatformContext>, int64_t, int64_t, int32_t, VideoChannelDescription::Quality, std::function<void(BroadcastPart &&)>)> requestVideoBroadcastPart; |
| 31 | std::function<void(uint32_t, float, bool)> updateAudioLevel; |
| 32 | std::shared_ptr<PlatformContext> platformContext; |
| 33 | }; |
| 34 |
| 35 | public: |
| 36 | StreamingMediaContext(StreamingMediaContextArguments &&arguments); |
| 37 | ~StreamingMediaContext(); |
| 38 |
| 39 | StreamingMediaContext& operator=(const StreamingMediaContext&) = delete; |
| 40 | StreamingMediaContext& operator=(StreamingMediaContext&&) = delete; |
| 41 |
| 42 | void setActiveVideoChannels(std::vector<VideoChannel> const &videoChannels); |
| 43 | void setVolume(uint32_t ssrc, double volume); |
| 44 | void addVideoSink(std::string const &endpointId, std::weak_ptr<rtc::VideoSinkInterface<webrtc::VideoFrame>> sink); |
| 45 |
| 46 | void getAudio(int16_t *audio_samples, const size_t num_samples, const size_t num_channels, const uint32_t samples_per_sec); |
| 47 |
| 48 | private: |
| 49 | std::shared_ptr<StreamingMediaContextPrivate> _private; |
| 50 | }; |
| 51 |
| 52 | } |
| 53 |
| 54 | #endif |
| 55 |