Roll src/third_party/WebKit eac3800:0237a66 (svn 202606:202607)
[chromium-blink-merge.git] / content / renderer / media / webrtc / media_stream_video_webrtc_sink.h
blob57c3702141c584546d1b10824ffe68f03685942e
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_
6 #define CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_
8 #include "base/macros.h"
9 #include "base/threading/thread_checker.h"
10 #include "content/public/renderer/media_stream_video_sink.h"
11 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
12 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
13 #include "third_party/libjingle/source/talk/app/webrtc/mediastreaminterface.h"
14 #include "third_party/libjingle/source/talk/app/webrtc/videosourceinterface.h"
16 namespace content {
18 class MediaStreamVideoTrack;
19 class PeerConnectionDependencyFactory;
21 // MediaStreamVideoWebRtcSink is an adapter between a
22 // content::MediaStreamVideoTrack object and a webrtc VideoTrack that is
23 // currently sent on a PeerConnection.
24 // The responsibility of the class is to create and own a representation of a
25 // webrtc VideoTrack that can be added and removed from a RTCPeerConnection. An
26 // instance of MediaStreamVideoWebRtcSink is created when a VideoTrack is added
27 // to an RTCPeerConnection object.
28 // Instances of this class is owned by the WebRtcMediaStreamAdapter object that
29 // created it.
30 class MediaStreamVideoWebRtcSink : public MediaStreamVideoSink {
31 public:
32 MediaStreamVideoWebRtcSink(const blink::WebMediaStreamTrack& track,
33 PeerConnectionDependencyFactory* factory);
34 ~MediaStreamVideoWebRtcSink() override;
36 webrtc::VideoTrackInterface* webrtc_video_track() {
37 return video_track_.get();
40 protected:
41 // Implementation of MediaStreamSink.
42 void OnEnabledChanged(bool enabled) override;
44 private:
45 // Used to DCHECK that we are called on the correct thread.
46 base::ThreadChecker thread_checker_;
48 scoped_refptr<webrtc::VideoTrackInterface> video_track_;
49 blink::WebMediaStreamTrack web_track_;
51 class WebRtcVideoSourceAdapter;
52 scoped_refptr<WebRtcVideoSourceAdapter> source_adapter_;
54 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoWebRtcSink);
57 } // namespace content
59 #endif // CONTENT_RENDERER_MEDIA_WEBRTC_WEBRTC_VIDEO_TRACK_ADAPTER_H_