Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / ppapi / proxy / media_stream_track_resource_base.h
blob0e7e9cc2854d0265d370bf0067b8925dc761bb09
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 PPAPI_PROXY_MEDIA_STREAM_TRACK_RESOURCE_BASE_H_
6 #define PPAPI_PROXY_MEDIA_STREAM_TRACK_RESOURCE_BASE_H_
8 #include "ppapi/proxy/plugin_resource.h"
9 #include "ppapi/proxy/ppapi_proxy_export.h"
10 #include "ppapi/shared_impl/media_stream_buffer_manager.h"
12 namespace ppapi {
13 namespace proxy {
15 class PPAPI_PROXY_EXPORT MediaStreamTrackResourceBase
16 : public PluginResource,
17 public MediaStreamBufferManager::Delegate {
18 protected:
19 MediaStreamTrackResourceBase(Connection connection,
20 PP_Instance instance,
21 int pending_renderer_id,
22 const std::string& id);
24 MediaStreamTrackResourceBase(Connection connection, PP_Instance instance);
26 ~MediaStreamTrackResourceBase() override;
28 std::string id() const { return id_; }
30 void set_id(const std::string& id) { id_ = id; }
32 bool has_ended() const { return has_ended_; }
34 MediaStreamBufferManager* buffer_manager() { return &buffer_manager_; }
36 void CloseInternal();
38 // Sends a buffer index to the corresponding PepperMediaStreamTrackHostBase
39 // via an IPC message. The host adds the buffer index into its
40 // |buffer_manager_| for reading or writing.
41 // Also see |MediaStreamBufferManager|.
42 void SendEnqueueBufferMessageToHost(int32_t index);
44 // PluginResource overrides:
45 void OnReplyReceived(const ResourceMessageReplyParams& params,
46 const IPC::Message& msg) override;
48 private:
49 // Message handlers:
50 void OnPluginMsgInitBuffers(const ResourceMessageReplyParams& params,
51 int32_t number_of_buffers,
52 int32_t buffer_size,
53 bool readonly);
54 void OnPluginMsgEnqueueBuffer(const ResourceMessageReplyParams& params,
55 int32_t index);
56 void OnPluginMsgEnqueueBuffers(const ResourceMessageReplyParams& params,
57 const std::vector<int32_t>& indices);
59 MediaStreamBufferManager buffer_manager_;
61 std::string id_;
63 bool has_ended_;
65 DISALLOW_COPY_AND_ASSIGN(MediaStreamTrackResourceBase);
68 } // namespace proxy
69 } // namespace ppapi
71 #endif // PPAPI_PROXY_MEDIA_STREAM_TRACK_RESOURCE_BASE_H_