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_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ | 5 #ifndef CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ |
6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ | 6 #define CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "content/common/content_export.h" | 9 #include "content/common/content_export.h" |
10 #include "ppapi/host/resource_host.h" | 10 #include "ppapi/host/resource_host.h" |
11 #include "ppapi/shared_impl/media_stream_frame_buffer.h" | 11 #include "ppapi/shared_impl/media_stream_buffer_manager.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 class RendererPpapiHost; | 15 class RendererPpapiHost; |
16 | 16 |
17 class PepperMediaStreamTrackHostBase | 17 class PepperMediaStreamTrackHostBase |
18 : public ppapi::host::ResourceHost, | 18 : public ppapi::host::ResourceHost, |
19 public ppapi::MediaStreamFrameBuffer::Delegate { | 19 public ppapi::MediaStreamBufferManager::Delegate { |
20 protected: | 20 protected: |
21 PepperMediaStreamTrackHostBase(RendererPpapiHost* host, | 21 PepperMediaStreamTrackHostBase(RendererPpapiHost* host, |
22 PP_Instance instance, | 22 PP_Instance instance, |
23 PP_Resource resource); | 23 PP_Resource resource); |
24 virtual ~PepperMediaStreamTrackHostBase(); | 24 virtual ~PepperMediaStreamTrackHostBase(); |
25 | 25 |
26 bool InitFrames(int32_t number_of_frames, int32_t frame_size); | 26 bool InitBuffers(int32_t number_of_buffers, int32_t buffer_size); |
27 | 27 |
28 ppapi::MediaStreamFrameBuffer* frame_buffer() { return &frame_buffer_; } | 28 ppapi::MediaStreamBufferManager* buffer_manager() { return &buffer_manager_; } |
29 | 29 |
30 // Sends a frame index to the corresponding MediaStreamTrackResourceBase | 30 // Sends a buffer index to the corresponding MediaStreamTrackResourceBase |
31 // via an IPC message. The resource adds the frame index into its | 31 // via an IPC message. The resource adds the buffer index into its |
32 // |frame_buffer_| for reading or writing. Also see |MediaStreamFrameBuffer|. | 32 // |buffer_manager_| for reading or writing. |
33 void SendEnqueueFrameMessageToPlugin(int32_t index); | 33 // Also see |MediaStreamBufferManager|. |
| 34 void SendEnqueueBufferMessageToPlugin(int32_t index); |
34 | 35 |
35 private: | 36 private: |
36 // Subclasses must implement this method to clean up when the track is closed. | 37 // Subclasses must implement this method to clean up when the track is closed. |
37 virtual void OnClose() = 0; | 38 virtual void OnClose() = 0; |
38 | 39 |
39 // ResourceMessageHandler overrides: | 40 // ResourceMessageHandler overrides: |
40 virtual int32_t OnResourceMessageReceived( | 41 virtual int32_t OnResourceMessageReceived( |
41 const IPC::Message& msg, | 42 const IPC::Message& msg, |
42 ppapi::host::HostMessageContext* context) OVERRIDE; | 43 ppapi::host::HostMessageContext* context) OVERRIDE; |
43 | 44 |
44 // Message handlers: | 45 // Message handlers: |
45 int32_t OnHostMsgEnqueueFrame(ppapi::host::HostMessageContext* context, | 46 int32_t OnHostMsgEnqueueBuffer(ppapi::host::HostMessageContext* context, |
46 int32_t index); | 47 int32_t index); |
47 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); | 48 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); |
48 | 49 |
49 RendererPpapiHost* host_; | 50 RendererPpapiHost* host_; |
50 | 51 |
51 ppapi::MediaStreamFrameBuffer frame_buffer_; | 52 ppapi::MediaStreamBufferManager buffer_manager_; |
52 | 53 |
53 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamTrackHostBase); | 54 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamTrackHostBase); |
54 }; | 55 }; |
55 | 56 |
56 } // namespace content | 57 } // namespace content |
57 | 58 |
58 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ | 59 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ |
OLD | NEW |