Assume the foo_test_run depends on everything needed to run the test.
[chromium-blink-merge.git] / content / renderer / pepper / pepper_media_stream_video_track_host.h
blob0b8218df39bfddbd57fdbe290f9e62d9b6a97218
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_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_
6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_
8 #include "base/compiler_specific.h"
9 #include "content/public/renderer/media_stream_video_sink.h"
10 #include "content/renderer/media/media_stream_video_source.h"
11 #include "content/renderer/pepper/pepper_media_stream_track_host_base.h"
12 #include "media/base/video_frame.h"
13 #include "ppapi/c/ppb_video_frame.h"
14 #include "ppapi/shared_impl/media_stream_video_track_shared.h"
15 #include "third_party/WebKit/public/platform/WebMediaStreamTrack.h"
16 #include "ui/gfx/size.h"
18 namespace content {
20 class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase,
21 public MediaStreamVideoSink,
22 public MediaStreamVideoSource {
23 public:
24 // Input mode constructor.
25 // In input mode, this class passes video frames from |track| to the
26 // associated pepper plugin.
27 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host,
28 PP_Instance instance,
29 PP_Resource resource,
30 const blink::WebMediaStreamTrack& track);
32 // Output mode constructor.
33 // In output mode, this class passes video frames from the associated
34 // pepper plugin to a newly created blink::WebMediaStreamTrack.
35 PepperMediaStreamVideoTrackHost(RendererPpapiHost* host,
36 PP_Instance instance,
37 PP_Resource resource);
39 virtual bool IsMediaStreamVideoTrackHost() OVERRIDE;
41 blink::WebMediaStreamTrack track() { return track_; }
43 private:
45 virtual ~PepperMediaStreamVideoTrackHost();
47 void InitBuffers();
49 // PepperMediaStreamTrackHostBase overrides:
50 virtual void OnClose() OVERRIDE;
51 virtual int32_t OnHostMsgEnqueueBuffer(
52 ppapi::host::HostMessageContext* context, int32_t index) OVERRIDE;
54 // Sends frame with |index| to |track_|.
55 int32_t SendFrameToTrack(int32_t index);
57 // MediaStreamVideoSink overrides:
58 virtual void OnVideoFrame(const scoped_refptr<media::VideoFrame>& frame)
59 OVERRIDE;
61 // MediaStreamVideoSource overrides:
62 virtual void GetCurrentSupportedFormats(int max_requested_width,
63 int max_requested_height) OVERRIDE;
64 virtual void StartSourceImpl(
65 const media::VideoCaptureParams& params) OVERRIDE;
67 virtual void StopSourceImpl() OVERRIDE;
69 // ResourceHost overrides:
70 virtual void DidConnectPendingHostToResource() OVERRIDE;
72 // ResourceMessageHandler overrides:
73 virtual int32_t OnResourceMessageReceived(
74 const IPC::Message& msg,
75 ppapi::host::HostMessageContext* context) OVERRIDE;
77 // Message handlers:
78 int32_t OnHostMsgConfigure(
79 ppapi::host::HostMessageContext* context,
80 const ppapi::MediaStreamVideoTrackShared::Attributes& attributes);
82 void InitBlinkTrack();
83 void OnTrackStarted(MediaStreamSource* source, bool success);
85 blink::WebMediaStreamTrack track_;
87 // True if it has been added to |blink::WebMediaStreamTrack| as a sink.
88 bool connected_;
90 // Number of buffers.
91 int32_t number_of_buffers_;
93 // Size of frames which are received from MediaStreamVideoSink.
94 gfx::Size source_frame_size_;
96 // Plugin specified frame size.
97 gfx::Size plugin_frame_size_;
99 // Format of frames which are received from MediaStreamVideoSink.
100 PP_VideoFrame_Format source_frame_format_;
102 // Plugin specified frame format.
103 PP_VideoFrame_Format plugin_frame_format_;
105 // The size of frame pixels in bytes.
106 uint32_t frame_data_size_;
108 // TODO(ronghuawu): Remove |type_| and split PepperMediaStreamVideoTrackHost
109 // into 2 classes for read and write.
110 TrackType type_;
111 bool output_started_;
113 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamVideoTrackHost);
116 } // namespace content
118 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_VIDEO_TRACK_HOST_H_