| #include <vector> |
| 6 | #include <stdint.h> |
| 7 |
| 8 | #include "api/video/video_frame.h" |
| 9 | #include "absl/types/optional.h" |
| 10 |
| 11 | #include "AudioStreamingPart.h" |
| 12 | #include "AudioStreamingPartInternal.h" |
| 13 |
| 14 | namespace tgcalls { |
| 15 |
| 16 | class VideoStreamingPartState; |
| 17 | class VideoStreamingSharedStateInternal; |
| 18 |
| 19 | struct VideoStreamingPartFrame { |
| 20 | std::string endpointId; |
| 21 | webrtc::VideoFrame frame; |
| 22 | double pts = 0; |
| 23 | int index = 0; |
| 24 |
| 25 | VideoStreamingPartFrame(std::string endpointId_, webrtc::VideoFrame const &frame_, double pts_, int index_) : |
| 26 | endpointId(endpointId_), |
| 27 | frame(frame_), |
| 28 | pts(pts_), |
| 29 | index(index_) { |
| 30 | } |
| 31 | }; |
| 32 |
| 33 | class VideoStreamingSharedState { |
| 34 | public: |
| 35 | VideoStreamingSharedState(); |
| 36 | ~VideoStreamingSharedState(); |
| 37 |
| 38 | VideoStreamingSharedStateInternal *impl() const { |
| 39 | return _impl; |
| 40 | } |
| 41 |
| 42 | private: |
| 43 | VideoStreamingSharedStateInternal *_impl = nullptr; |
| 44 | }; |
| 45 |
| 46 | class VideoStreamingPart { |
| 47 | public: |
| 48 | enum class ContentType { |
| 49 | Audio, |
| 50 | Video |
| 51 | }; |
| 52 |
| 53 | public: |
| 54 | explicit VideoStreamingPart(std::vector<uint8_t> &&data, VideoStreamingPart::ContentType contentType); |
| 55 | ~VideoStreamingPart(); |
| 56 |
| 57 | VideoStreamingPart(const VideoStreamingPart&) = delete; |
| 58 | VideoStreamingPart(VideoStreamingPart&& other) { |
| 59 | _state = other._state; |
| 60 | other._state = nullptr; |
| 61 | } |
| 62 | VideoStreamingPart& operator=(const VideoStreamingPart&) = delete; |
| 63 | VideoStreamingPart& operator=(VideoStreamingPart&&) = delete; |
| 64 |
| 65 | absl::optional<VideoStreamingPartFrame> getFrameAtRelativeTimestamp(VideoStreamingSharedState const *sharedState, double timestamp); |
| 66 | absl::optional<std::string> getActiveEndpointId() const; |
| 67 | bool hasRemainingFrames() const; |
| 68 |
| 69 | int getAudioRemainingMilliseconds(); |
| 70 | std::vector<AudioStreamingPart::StreamingPartChannel> getAudio10msPerChannel(AudioStreamingPartPersistentDecoder &persistentDecoder); |
| 71 |
| 72 | private: |
| 73 | VideoStreamingPartState *_state = nullptr; |
| 74 | }; |
| 75 |
| 76 | } |
| 77 |
| 78 | #endif |
| 79 |