| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_ | 6 #define CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_ |
| 7 | 7 |
| 8 #include <memory> |
| 9 |
| 8 #include "base/macros.h" | 10 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
| 10 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 11 #include "content/common/content_export.h" | 13 #include "content/common/content_export.h" |
| 12 #include "content/renderer/media/media_stream_video_source.h" | 14 #include "content/renderer/media/media_stream_video_source.h" |
| 13 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" | 15 #include "third_party/WebKit/public/platform/WebMediaStreamSource.h" |
| 14 #include "third_party/webrtc/api/mediastreaminterface.h" | 16 #include "third_party/webrtc/api/mediastreaminterface.h" |
| 15 | 17 |
| 16 namespace content { | 18 namespace content { |
| 17 | 19 |
| 18 class TrackObserver; | 20 class TrackObserver; |
| 19 | 21 |
| 20 // MediaStreamRemoteVideoSource implements the MediaStreamVideoSource interface | 22 // MediaStreamRemoteVideoSource implements the MediaStreamVideoSource interface |
| 21 // for video tracks received on a PeerConnection. The purpose of the class is | 23 // for video tracks received on a PeerConnection. The purpose of the class is |
| 22 // to make sure there is no difference between a video track where the source is | 24 // to make sure there is no difference between a video track where the source is |
| 23 // a local source and a video track where the source is a remote video track. | 25 // a local source and a video track where the source is a remote video track. |
| 24 class CONTENT_EXPORT MediaStreamRemoteVideoSource | 26 class CONTENT_EXPORT MediaStreamRemoteVideoSource |
| 25 : public MediaStreamVideoSource { | 27 : public MediaStreamVideoSource { |
| 26 public: | 28 public: |
| 27 MediaStreamRemoteVideoSource(std::unique_ptr<TrackObserver> observer); | 29 explicit MediaStreamRemoteVideoSource( |
| 30 std::unique_ptr<TrackObserver> observer); |
| 28 ~MediaStreamRemoteVideoSource() override; | 31 ~MediaStreamRemoteVideoSource() override; |
| 29 | 32 |
| 30 // Should be called when the remote video track this source originates from is | 33 // Should be called when the remote video track this source originates from is |
| 31 // no longer received on a PeerConnection. This cleans up the references to | 34 // no longer received on a PeerConnection. This cleans up the references to |
| 32 // the webrtc::MediaStreamTrackInterface instance held by |observer_|. | 35 // the webrtc::MediaStreamTrackInterface instance held by |observer_|. |
| 33 void OnSourceTerminated(); | 36 void OnSourceTerminated(); |
| 34 | 37 |
| 35 protected: | 38 protected: |
| 36 // Implements MediaStreamVideoSource. | 39 // Implements MediaStreamVideoSource. |
| 37 void GetCurrentSupportedFormats( | |
| 38 int max_requested_width, | |
| 39 int max_requested_height, | |
| 40 double max_requested_frame_rate, | |
| 41 const VideoCaptureDeviceFormatsCB& callback) override; | |
| 42 | |
| 43 void StartSourceImpl( | 40 void StartSourceImpl( |
| 44 const media::VideoCaptureFormat& format, | 41 const media::VideoCaptureFormat& format, |
| 45 const blink::WebMediaConstraints& constraints, | 42 const blink::WebMediaConstraints& constraints, |
| 46 const VideoCaptureDeliverFrameCB& frame_callback) override; | 43 const VideoCaptureDeliverFrameCB& frame_callback) override; |
| 47 | 44 |
| 48 void StopSourceImpl() override; | 45 void StopSourceImpl() override; |
| 49 | 46 |
| 50 // Used by tests to test that a frame can be received and that the | 47 // Used by tests to test that a frame can be received and that the |
| 51 // MediaStreamRemoteVideoSource behaves as expected. | 48 // MediaStreamRemoteVideoSource behaves as expected. |
| 52 rtc::VideoSinkInterface<webrtc::VideoFrame>* SinkInterfaceForTest(); | 49 rtc::VideoSinkInterface<webrtc::VideoFrame>* SinkInterfaceForTest(); |
| 53 | 50 |
| 54 private: | 51 private: |
| 55 void OnChanged(webrtc::MediaStreamTrackInterface::TrackState state); | 52 void OnChanged(webrtc::MediaStreamTrackInterface::TrackState state); |
| 56 | 53 |
| 57 // Internal class used for receiving frames from the webrtc track on a | 54 // Internal class used for receiving frames from the webrtc track on a |
| 58 // libjingle thread and forward it to the IO-thread. | 55 // libjingle thread and forward it to the IO-thread. |
| 59 class RemoteVideoSourceDelegate; | 56 class RemoteVideoSourceDelegate; |
| 60 scoped_refptr<RemoteVideoSourceDelegate> delegate_; | 57 scoped_refptr<RemoteVideoSourceDelegate> delegate_; |
| 61 std::unique_ptr<TrackObserver> observer_; | 58 std::unique_ptr<TrackObserver> observer_; |
| 62 | 59 |
| 63 DISALLOW_COPY_AND_ASSIGN(MediaStreamRemoteVideoSource); | 60 DISALLOW_COPY_AND_ASSIGN(MediaStreamRemoteVideoSource); |
| 64 }; | 61 }; |
| 65 | 62 |
| 66 } // namespace content | 63 } // namespace content |
| 67 | 64 |
| 68 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_ | 65 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_MEDIA_STREAM_REMOTE_VIDEO_SOURCE_H_ |
| OLD | NEW |