123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336 |
- #ifndef API_MEDIA_STREAM_INTERFACE_H_
- #define API_MEDIA_STREAM_INTERFACE_H_
- #include <stddef.h>
- #include <string>
- #include <vector>
- #include "absl/types/optional.h"
- #include "api/audio_options.h"
- #include "api/scoped_refptr.h"
- #include "api/video/recordable_encoded_frame.h"
- #include "api/video/video_frame.h"
- #include "api/video/video_sink_interface.h"
- #include "api/video/video_source_interface.h"
- #include "modules/audio_processing/include/audio_processing_statistics.h"
- #include "rtc_base/ref_count.h"
- #include "rtc_base/system/rtc_export.h"
- namespace webrtc {
- class ObserverInterface {
- public:
- virtual void OnChanged() = 0;
- protected:
- virtual ~ObserverInterface() {}
- };
- class NotifierInterface {
- public:
- virtual void RegisterObserver(ObserverInterface* observer) = 0;
- virtual void UnregisterObserver(ObserverInterface* observer) = 0;
- virtual ~NotifierInterface() {}
- };
- class RTC_EXPORT MediaSourceInterface : public rtc::RefCountInterface,
- public NotifierInterface {
- public:
- enum SourceState { kInitializing, kLive, kEnded, kMuted };
- virtual SourceState state() const = 0;
- virtual bool remote() const = 0;
- protected:
- ~MediaSourceInterface() override = default;
- };
- class RTC_EXPORT MediaStreamTrackInterface : public rtc::RefCountInterface,
- public NotifierInterface {
- public:
- enum TrackState {
- kLive,
- kEnded,
- };
- static const char* const kAudioKind;
- static const char* const kVideoKind;
-
-
-
-
- virtual std::string kind() const = 0;
-
- virtual std::string id() const = 0;
-
-
- virtual bool enabled() const = 0;
- virtual bool set_enabled(bool enable) = 0;
-
- virtual TrackState state() const = 0;
- protected:
- ~MediaStreamTrackInterface() override = default;
- };
- class VideoTrackSourceInterface : public MediaSourceInterface,
- public rtc::VideoSourceInterface<VideoFrame> {
- public:
- struct Stats {
-
- int input_width;
- int input_height;
- };
-
-
-
-
-
- virtual bool is_screencast() const = 0;
-
-
-
-
-
- virtual absl::optional<bool> needs_denoising() const = 0;
-
-
-
-
- virtual bool GetStats(Stats* stats) = 0;
-
- virtual bool SupportsEncodedOutput() const = 0;
-
-
- virtual void GenerateKeyFrame() = 0;
-
-
-
-
-
- virtual void AddEncodedSink(
- rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) = 0;
-
- virtual void RemoveEncodedSink(
- rtc::VideoSinkInterface<RecordableEncodedFrame>* sink) = 0;
- protected:
- ~VideoTrackSourceInterface() override = default;
- };
- class RTC_EXPORT VideoTrackInterface
- : public MediaStreamTrackInterface,
- public rtc::VideoSourceInterface<VideoFrame> {
- public:
-
-
-
- enum class ContentHint { kNone, kFluid, kDetailed, kText };
-
-
- void AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
- const rtc::VideoSinkWants& wants) override {}
- void RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) override {}
- virtual VideoTrackSourceInterface* GetSource() const = 0;
- virtual ContentHint content_hint() const;
- virtual void set_content_hint(ContentHint hint) {}
- protected:
- ~VideoTrackInterface() override = default;
- };
- class AudioTrackSinkInterface {
- public:
- virtual void OnData(const void* audio_data,
- int bits_per_sample,
- int sample_rate,
- size_t number_of_channels,
- size_t number_of_frames) {
- RTC_NOTREACHED() << "This method must be overridden, or not used.";
- }
-
-
-
-
- virtual void OnData(const void* audio_data,
- int bits_per_sample,
- int sample_rate,
- size_t number_of_channels,
- size_t number_of_frames,
- absl::optional<int64_t> absolute_capture_timestamp_ms) {
-
-
- return OnData(audio_data, bits_per_sample, sample_rate, number_of_channels,
- number_of_frames);
- }
- protected:
- virtual ~AudioTrackSinkInterface() {}
- };
- class RTC_EXPORT AudioSourceInterface : public MediaSourceInterface {
- public:
- class AudioObserver {
- public:
- virtual void OnSetVolume(double volume) = 0;
- protected:
- virtual ~AudioObserver() {}
- };
-
-
-
-
-
- virtual void SetVolume(double volume) {}
-
- virtual void RegisterAudioObserver(AudioObserver* observer) {}
- virtual void UnregisterAudioObserver(AudioObserver* observer) {}
-
- virtual void AddSink(AudioTrackSinkInterface* sink) {}
- virtual void RemoveSink(AudioTrackSinkInterface* sink) {}
-
-
-
- virtual const cricket::AudioOptions options() const;
- };
- class AudioProcessorInterface : public rtc::RefCountInterface {
- public:
- struct AudioProcessorStatistics {
- bool typing_noise_detected = false;
- AudioProcessingStats apm_statistics;
- };
-
-
-
-
-
- virtual AudioProcessorStatistics GetStats(bool has_remote_tracks) = 0;
- protected:
- ~AudioProcessorInterface() override = default;
- };
- class RTC_EXPORT AudioTrackInterface : public MediaStreamTrackInterface {
- public:
-
-
- virtual AudioSourceInterface* GetSource() const = 0;
-
- virtual void AddSink(AudioTrackSinkInterface* sink) = 0;
- virtual void RemoveSink(AudioTrackSinkInterface* sink) = 0;
-
-
-
-
- virtual bool GetSignalLevel(int* level);
-
-
-
- virtual rtc::scoped_refptr<AudioProcessorInterface> GetAudioProcessor();
- protected:
- ~AudioTrackInterface() override = default;
- };
- typedef std::vector<rtc::scoped_refptr<AudioTrackInterface> > AudioTrackVector;
- typedef std::vector<rtc::scoped_refptr<VideoTrackInterface> > VideoTrackVector;
- class MediaStreamInterface : public rtc::RefCountInterface,
- public NotifierInterface {
- public:
- virtual std::string id() const = 0;
- virtual AudioTrackVector GetAudioTracks() = 0;
- virtual VideoTrackVector GetVideoTracks() = 0;
- virtual rtc::scoped_refptr<AudioTrackInterface> FindAudioTrack(
- const std::string& track_id) = 0;
- virtual rtc::scoped_refptr<VideoTrackInterface> FindVideoTrack(
- const std::string& track_id) = 0;
- virtual bool AddTrack(AudioTrackInterface* track) = 0;
- virtual bool AddTrack(VideoTrackInterface* track) = 0;
- virtual bool RemoveTrack(AudioTrackInterface* track) = 0;
- virtual bool RemoveTrack(VideoTrackInterface* track) = 0;
- protected:
- ~MediaStreamInterface() override = default;
- };
- }
- #endif
|