| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack { | 29 class CONTENT_EXPORT MediaStreamVideoTrack : public MediaStreamTrack { |
| 30 public: | 30 public: |
| 31 // Help method to create a blink::WebMediaStreamTrack and a | 31 // Help method to create a blink::WebMediaStreamTrack and a |
| 32 // MediaStreamVideoTrack instance. The MediaStreamVideoTrack object is owned | 32 // MediaStreamVideoTrack instance. The MediaStreamVideoTrack object is owned |
| 33 // by the blink object in its WebMediaStreamTrack::ExtraData member. | 33 // by the blink object in its WebMediaStreamTrack::ExtraData member. |
| 34 // |callback| is triggered if the track is added to the source | 34 // |callback| is triggered if the track is added to the source |
| 35 // successfully and will receive video frames that match the given settings | 35 // successfully and will receive video frames that match the given settings |
| 36 // or if the source fails to provide video frames. | 36 // or if the source fails to provide video frames. |
| 37 // If |enabled| is true, sinks added to the track will | 37 // If |enabled| is true, sinks added to the track will |
| 38 // receive video frames when the source delivers frames to the track. | 38 // receive video frames when the source delivers frames to the track. |
| 39 // TODO(guidou): Remove the variant that takes a |constraints| argument. | |
| 40 // http://crbug.com/706408 | |
| 41 static blink::WebMediaStreamTrack CreateVideoTrack( | 39 static blink::WebMediaStreamTrack CreateVideoTrack( |
| 42 MediaStreamVideoSource* source, | 40 MediaStreamVideoSource* source, |
| 43 const MediaStreamVideoSource::ConstraintsCallback& callback, | 41 const MediaStreamVideoSource::ConstraintsCallback& callback, |
| 44 bool enabled); | 42 bool enabled); |
| 45 static blink::WebMediaStreamTrack CreateVideoTrack( | 43 static blink::WebMediaStreamTrack CreateVideoTrack( |
| 46 MediaStreamVideoSource* source, | 44 MediaStreamVideoSource* source, |
| 47 const blink::WebMediaConstraints& constraints, | |
| 48 const MediaStreamVideoSource::ConstraintsCallback& callback, | |
| 49 bool enabled); | |
| 50 static blink::WebMediaStreamTrack CreateVideoTrack( | |
| 51 MediaStreamVideoSource* source, | |
| 52 const VideoTrackAdapterSettings& adapter_settings, | 45 const VideoTrackAdapterSettings& adapter_settings, |
| 53 const base::Optional<bool>& noise_reduction, | 46 const base::Optional<bool>& noise_reduction, |
| 54 bool is_screencast, | 47 bool is_screencast, |
| 55 const base::Optional<double>& min_frame_rate, | 48 const base::Optional<double>& min_frame_rate, |
| 56 const MediaStreamVideoSource::ConstraintsCallback& callback, | 49 const MediaStreamVideoSource::ConstraintsCallback& callback, |
| 57 bool enabled); | 50 bool enabled); |
| 58 | 51 |
| 59 static MediaStreamVideoTrack* GetVideoTrack( | 52 static MediaStreamVideoTrack* GetVideoTrack( |
| 60 const blink::WebMediaStreamTrack& track); | 53 const blink::WebMediaStreamTrack& track); |
| 61 | 54 |
| 62 // Constructors for video tracks. | 55 // Constructors for video tracks. |
| 63 // TODO(guidou): Remove the variant that takes a |constraints| argument. | |
| 64 // http://crbug.com/706408 | |
| 65 MediaStreamVideoTrack( | 56 MediaStreamVideoTrack( |
| 66 MediaStreamVideoSource* source, | 57 MediaStreamVideoSource* source, |
| 67 const MediaStreamVideoSource::ConstraintsCallback& callback, | 58 const MediaStreamVideoSource::ConstraintsCallback& callback, |
| 68 bool enabled); | 59 bool enabled); |
| 69 MediaStreamVideoTrack( | 60 MediaStreamVideoTrack( |
| 70 MediaStreamVideoSource* source, | |
| 71 const blink::WebMediaConstraints& constraints, | |
| 72 const MediaStreamVideoSource::ConstraintsCallback& callback, | |
| 73 bool enabled); | |
| 74 MediaStreamVideoTrack( | |
| 75 MediaStreamVideoSource* source, | 61 MediaStreamVideoSource* source, |
| 76 const VideoTrackAdapterSettings& adapter_settings, | 62 const VideoTrackAdapterSettings& adapter_settings, |
| 77 const base::Optional<bool>& noise_reduction, | 63 const base::Optional<bool>& noise_reduction, |
| 78 bool is_screen_cast, | 64 bool is_screen_cast, |
| 79 const base::Optional<double>& min_frame_rate, | 65 const base::Optional<double>& min_frame_rate, |
| 80 const MediaStreamVideoSource::ConstraintsCallback& callback, | 66 const MediaStreamVideoSource::ConstraintsCallback& callback, |
| 81 bool enabled); | 67 bool enabled); |
| 82 ~MediaStreamVideoTrack() override; | 68 ~MediaStreamVideoTrack() override; |
| 83 | 69 |
| 84 // MediaStreamTrack overrides. | 70 // MediaStreamTrack overrides. |
| 85 void SetEnabled(bool enabled) override; | 71 void SetEnabled(bool enabled) override; |
| 86 void SetContentHint( | 72 void SetContentHint( |
| 87 blink::WebMediaStreamTrack::ContentHintType content_hint) override; | 73 blink::WebMediaStreamTrack::ContentHintType content_hint) override; |
| 88 void Stop() override; | 74 void Stop() override; |
| 89 void GetSettings(blink::WebMediaStreamTrack::Settings& settings) override; | 75 void GetSettings(blink::WebMediaStreamTrack::Settings& settings) override; |
| 90 | 76 |
| 91 void OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state); | 77 void OnReadyStateChanged(blink::WebMediaStreamSource::ReadyState state); |
| 92 | 78 |
| 93 const blink::WebMediaConstraints& constraints() const { | |
| 94 DCHECK(IsOldVideoConstraints()); | |
| 95 return constraints_; | |
| 96 } | |
| 97 const base::Optional<bool>& noise_reduction() const { | 79 const base::Optional<bool>& noise_reduction() const { |
| 98 DCHECK(!IsOldVideoConstraints()); | |
| 99 return noise_reduction_; | 80 return noise_reduction_; |
| 100 } | 81 } |
| 101 bool is_screencast() const { | 82 bool is_screencast() const { |
| 102 DCHECK(!IsOldVideoConstraints()); | |
| 103 return is_screencast_; | 83 return is_screencast_; |
| 104 } | 84 } |
| 105 const base::Optional<double>& min_frame_rate() const { | 85 const base::Optional<double>& min_frame_rate() const { |
| 106 DCHECK(!IsOldVideoConstraints()); | |
| 107 return min_frame_rate_; | 86 return min_frame_rate_; |
| 108 } | 87 } |
| 109 const base::Optional<double>& max_frame_rate() const { | 88 const base::Optional<double>& max_frame_rate() const { |
| 110 DCHECK(!IsOldVideoConstraints()); | |
| 111 return max_frame_rate_; | 89 return max_frame_rate_; |
| 112 } | 90 } |
| 113 const VideoTrackAdapterSettings& adapter_settings() const { | 91 const VideoTrackAdapterSettings& adapter_settings() const { |
| 114 DCHECK(!IsOldVideoConstraints()); | |
| 115 return *adapter_settings_; | 92 return *adapter_settings_; |
| 116 } | 93 } |
| 117 | 94 |
| 118 // Setting information about the track size. | 95 // Setting information about the track size. |
| 119 // Called from MediaStreamVideoSource at track initialization. | 96 // Called from MediaStreamVideoSource at track initialization. |
| 120 void SetTargetSizeAndFrameRate(int width, int height, double frame_rate) { | 97 void SetTargetSizeAndFrameRate(int width, int height, double frame_rate) { |
| 121 width_ = width; | 98 width_ = width; |
| 122 height_ = height; | 99 height_ = height; |
| 123 frame_rate_ = frame_rate; | 100 frame_rate_ = frame_rate; |
| 124 } | 101 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 142 bool is_sink_secure); | 119 bool is_sink_secure); |
| 143 void RemoveSink(MediaStreamVideoSink* sink); | 120 void RemoveSink(MediaStreamVideoSink* sink); |
| 144 | 121 |
| 145 std::vector<MediaStreamVideoSink*> sinks_; | 122 std::vector<MediaStreamVideoSink*> sinks_; |
| 146 | 123 |
| 147 // |FrameDeliverer| is an internal helper object used for delivering video | 124 // |FrameDeliverer| is an internal helper object used for delivering video |
| 148 // frames on the IO-thread using callbacks to all registered tracks. | 125 // frames on the IO-thread using callbacks to all registered tracks. |
| 149 class FrameDeliverer; | 126 class FrameDeliverer; |
| 150 const scoped_refptr<FrameDeliverer> frame_deliverer_; | 127 const scoped_refptr<FrameDeliverer> frame_deliverer_; |
| 151 | 128 |
| 152 // TODO(guidou): remove this field. http://crbug.com/706408 | |
| 153 const blink::WebMediaConstraints constraints_; | |
| 154 | |
| 155 // TODO(guidou): Make this field a regular field instead of a unique_ptr. | 129 // TODO(guidou): Make this field a regular field instead of a unique_ptr. |
| 156 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings_; | 130 std::unique_ptr<VideoTrackAdapterSettings> adapter_settings_; |
| 157 base::Optional<bool> noise_reduction_; | 131 base::Optional<bool> noise_reduction_; |
| 158 bool is_screencast_; | 132 bool is_screencast_; |
| 159 base::Optional<double> min_frame_rate_; | 133 base::Optional<double> min_frame_rate_; |
| 160 base::Optional<double> max_frame_rate_; | 134 base::Optional<double> max_frame_rate_; |
| 161 | 135 |
| 162 // Weak ref to the source this tracks is connected to. | 136 // Weak ref to the source this tracks is connected to. |
| 163 base::WeakPtr<MediaStreamVideoSource> source_; | 137 base::WeakPtr<MediaStreamVideoSource> source_; |
| 164 | 138 |
| 165 // This is used for tracking if all connected video sinks are secure. | 139 // This is used for tracking if all connected video sinks are secure. |
| 166 SecureDisplayLinkTracker<MediaStreamVideoSink> secure_tracker_; | 140 SecureDisplayLinkTracker<MediaStreamVideoSink> secure_tracker_; |
| 167 | 141 |
| 168 // Remembering our desired video size and frame rate. | 142 // Remembering our desired video size and frame rate. |
| 169 int width_ = 0; | 143 int width_ = 0; |
| 170 int height_ = 0; | 144 int height_ = 0; |
| 171 double frame_rate_ = 0.0; | 145 double frame_rate_ = 0.0; |
| 172 | 146 |
| 173 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack); | 147 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrack); |
| 174 }; | 148 }; |
| 175 | 149 |
| 176 } // namespace content | 150 } // namespace content |
| 177 | 151 |
| 178 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ | 152 #endif // CONTENT_RENDERER_MEDIA_MEDIA_STREAM_VIDEO_TRACK_H_ |
| OLD | NEW |