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_buffer_manager.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::MediaStreamBufferManager::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 ~PepperMediaStreamTrackHostBase() override; |
25 | 25 |
26 enum TrackType { | 26 enum TrackType { |
27 kRead, | 27 kRead, |
28 kWrite | 28 kWrite |
29 }; | 29 }; |
30 bool InitBuffers(int32_t number_of_buffers, | 30 bool InitBuffers(int32_t number_of_buffers, |
31 int32_t buffer_size, | 31 int32_t buffer_size, |
32 TrackType track_type); | 32 TrackType track_type); |
33 | 33 |
34 ppapi::MediaStreamBufferManager* buffer_manager() { return &buffer_manager_; } | 34 ppapi::MediaStreamBufferManager* buffer_manager() { return &buffer_manager_; } |
35 | 35 |
36 // Sends a buffer index to the corresponding MediaStreamTrackResourceBase | 36 // Sends a buffer index to the corresponding MediaStreamTrackResourceBase |
37 // via an IPC message. The resource adds the buffer index into its | 37 // via an IPC message. The resource adds the buffer index into its |
38 // |buffer_manager_| for reading or writing. | 38 // |buffer_manager_| for reading or writing. |
39 // Also see |MediaStreamBufferManager|. | 39 // Also see |MediaStreamBufferManager|. |
40 void SendEnqueueBufferMessageToPlugin(int32_t index); | 40 void SendEnqueueBufferMessageToPlugin(int32_t index); |
41 | 41 |
42 // Sends a set of buffer indices to the corresponding | 42 // Sends a set of buffer indices to the corresponding |
43 // MediaStreamTrackResourceBase via an IPC message. | 43 // MediaStreamTrackResourceBase via an IPC message. |
44 // The resource adds the buffer indices into its | 44 // The resource adds the buffer indices into its |
45 // |frame_buffer_| for reading or writing. Also see |MediaStreamFrameBuffer|. | 45 // |frame_buffer_| for reading or writing. Also see |MediaStreamFrameBuffer|. |
46 void SendEnqueueBuffersMessageToPlugin(const std::vector<int32_t>& indices); | 46 void SendEnqueueBuffersMessageToPlugin(const std::vector<int32_t>& indices); |
47 | 47 |
48 // ResourceMessageHandler overrides: | 48 // ResourceMessageHandler overrides: |
49 virtual int32_t OnResourceMessageReceived( | 49 int32_t OnResourceMessageReceived( |
50 const IPC::Message& msg, | 50 const IPC::Message& msg, |
51 ppapi::host::HostMessageContext* context) override; | 51 ppapi::host::HostMessageContext* context) override; |
52 | 52 |
53 // Message handlers: | 53 // Message handlers: |
54 virtual int32_t OnHostMsgEnqueueBuffer( | 54 virtual int32_t OnHostMsgEnqueueBuffer( |
55 ppapi::host::HostMessageContext* context, int32_t index); | 55 ppapi::host::HostMessageContext* context, int32_t index); |
56 | 56 |
57 private: | 57 private: |
58 // Subclasses must implement this method to clean up when the track is closed. | 58 // Subclasses must implement this method to clean up when the track is closed. |
59 virtual void OnClose() = 0; | 59 virtual void OnClose() = 0; |
60 | 60 |
61 // Message handlers: | 61 // Message handlers: |
62 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); | 62 int32_t OnHostMsgClose(ppapi::host::HostMessageContext* context); |
63 | 63 |
64 RendererPpapiHost* host_; | 64 RendererPpapiHost* host_; |
65 | 65 |
66 ppapi::MediaStreamBufferManager buffer_manager_; | 66 ppapi::MediaStreamBufferManager buffer_manager_; |
67 | 67 |
68 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamTrackHostBase); | 68 DISALLOW_COPY_AND_ASSIGN(PepperMediaStreamTrackHostBase); |
69 }; | 69 }; |
70 | 70 |
71 } // namespace content | 71 } // namespace content |
72 | 72 |
73 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ | 73 #endif // CONTENT_RENDERER_PEPPER_PEPPER_MEDIA_STREAM_TRACK_HOST_BASE_H_ |
OLD | NEW |