OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/memory/ref_counted.h" | |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "base/memory/weak_ptr.h" | 11 #include "base/memory/weak_ptr.h" |
11 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
12 #include "content/renderer/media/video_source_handler.h" | 13 #include "content/renderer/media/video_source_handler.h" |
13 #include "ppapi/c/pp_time.h" | 14 #include "ppapi/c/pp_time.h" |
14 #include "ppapi/host/host_message_context.h" | 15 #include "ppapi/host/host_message_context.h" |
15 #include "ppapi/host/resource_host.h" | 16 #include "ppapi/host/resource_host.h" |
16 | 17 |
18 struct PP_ImageDataDesc; | |
19 | |
17 namespace content { | 20 namespace content { |
18 | 21 |
19 class RendererPpapiHost; | 22 class RendererPpapiHost; |
20 | 23 |
21 class CONTENT_EXPORT PepperVideoSourceHost | 24 class CONTENT_EXPORT PepperVideoSourceHost |
22 : public ppapi::host::ResourceHost, | 25 : public ppapi::host::ResourceHost { |
raymes
2013/05/10 15:14:48
nit: I think this might fit on the above line
bbudge
2013/05/10 17:38:21
Done.
| |
23 public content::FrameReaderInterface { | |
24 public: | 26 public: |
25 PepperVideoSourceHost(RendererPpapiHost* host, | 27 PepperVideoSourceHost(RendererPpapiHost* host, |
26 PP_Instance instance, | 28 PP_Instance instance, |
27 PP_Resource resource); | 29 PP_Resource resource); |
28 | 30 |
29 virtual ~PepperVideoSourceHost(); | 31 virtual ~PepperVideoSourceHost(); |
30 | 32 |
31 // content::FrameReaderInterface implementation. | |
32 virtual bool GotFrame(cricket::VideoFrame* frame) OVERRIDE; | |
33 | |
34 virtual int32_t OnResourceMessageReceived( | 33 virtual int32_t OnResourceMessageReceived( |
35 const IPC::Message& msg, | 34 const IPC::Message& msg, |
36 ppapi::host::HostMessageContext* context) OVERRIDE; | 35 ppapi::host::HostMessageContext* context) OVERRIDE; |
37 | 36 |
38 private: | 37 private: |
38 // This helper object receives frames on a video worker thread and passes | |
39 // them on to us. | |
40 class FrameReceiver : public content::FrameReaderInterface, | |
41 public base::RefCountedThreadSafe<FrameReceiver> { | |
42 public: | |
43 explicit FrameReceiver(const base::WeakPtr<PepperVideoSourceHost>& host); | |
44 | |
45 // content::FrameReaderInterface implementation. | |
46 virtual bool GotFrame(cricket::VideoFrame* frame) OVERRIDE; | |
47 | |
48 void OnGotFrame(scoped_ptr<cricket::VideoFrame> frame); | |
49 | |
50 private: | |
51 friend class base::RefCountedThreadSafe<FrameReceiver>; | |
52 virtual ~FrameReceiver(); | |
53 | |
54 base::WeakPtr<PepperVideoSourceHost> host_; | |
55 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; | |
56 }; | |
57 | |
58 friend class FrameReceiver; | |
59 | |
39 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, | 60 int32_t OnHostMsgOpen(ppapi::host::HostMessageContext* context, |
40 const std::string& stream_url); | 61 const std::string& stream_url); |
41 int32_t OnHostMsgGetFrame(ppapi::host::HostMessageContext* context); | 62 int32_t OnHostMsgGetFrame(ppapi::host::HostMessageContext* context); |
42 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); | 63 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); |
43 | 64 |
44 void OnGotFrame(scoped_ptr<cricket::VideoFrame> frame); | 65 void SendGetFrameReply(); |
raymes
2013/05/10 15:14:48
nit: Might be nice to have comments for these. See
bbudge
2013/05/10 17:38:21
Done.
| |
66 void ReportGetFrameError(int32_t error); | |
45 | 67 |
46 int32_t ConvertFrame(ppapi::HostResource* image_data_resource, | |
47 PP_TimeTicks* timestamp); | |
48 void SendFrame(const ppapi::HostResource& image_data_resource, | |
49 PP_TimeTicks timestamp, | |
50 int32_t result); | |
51 void Close(); | 68 void Close(); |
52 | 69 |
53 RendererPpapiHost* renderer_ppapi_host_; | 70 RendererPpapiHost* renderer_ppapi_host_; |
54 | 71 |
55 base::WeakPtrFactory<PepperVideoSourceHost> weak_factory_; | 72 base::WeakPtrFactory<PepperVideoSourceHost> weak_factory_; |
56 | 73 |
57 ppapi::host::ReplyMessageContext reply_context_; | 74 ppapi::host::ReplyMessageContext reply_context_; |
58 scoped_refptr<base::MessageLoopProxy> main_message_loop_proxy_; | |
59 | 75 |
60 scoped_ptr<content::VideoSourceHandler> source_handler_; | 76 scoped_ptr<content::VideoSourceHandler> source_handler_; |
77 scoped_refptr<FrameReceiver> frame_receiver_; | |
61 std::string stream_url_; | 78 std::string stream_url_; |
62 scoped_ptr<cricket::VideoFrame> last_frame_; | 79 scoped_ptr<cricket::VideoFrame> last_frame_; |
63 bool get_frame_pending_; | 80 bool get_frame_pending_; |
64 | 81 |
65 DISALLOW_COPY_AND_ASSIGN(PepperVideoSourceHost); | 82 DISALLOW_COPY_AND_ASSIGN(PepperVideoSourceHost); |
66 }; | 83 }; |
67 | 84 |
68 } // namespace content | 85 } // namespace content |
69 | 86 |
70 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ | 87 #endif // CONTENT_RENDERER_PEPPER_PEPPER_VIDEO_SOURCE_HOST_H_ |
OLD | NEW |