Elim cr-checkbox
[chromium-blink-merge.git] / ppapi / proxy / media_stream_audio_track_resource.h
blob566f42d96caeef9bd7f4031d97529e1723537761
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_AUDIO_TRACK_RESOURCE_H_
6 #define PPAPI_PROXY_MEDIA_STREAM_AUDIO_TRACK_RESOURCE_H_
8 #include <map>
9 #include <string>
11 #include "base/memory/ref_counted.h"
12 #include "ppapi/proxy/media_stream_track_resource_base.h"
13 #include "ppapi/proxy/ppapi_proxy_export.h"
14 #include "ppapi/thunk/ppb_media_stream_audio_track_api.h"
16 namespace ppapi {
17 namespace proxy {
19 class AudioBufferResource;
21 class PPAPI_PROXY_EXPORT MediaStreamAudioTrackResource
22 : public MediaStreamTrackResourceBase,
23 public thunk::PPB_MediaStreamAudioTrack_API {
24 public:
25 MediaStreamAudioTrackResource(Connection connection,
26 PP_Instance instance,
27 int pending_renderer_id,
28 const std::string& id);
30 ~MediaStreamAudioTrackResource() override;
32 // Resource overrides:
33 thunk::PPB_MediaStreamAudioTrack_API* AsPPB_MediaStreamAudioTrack_API()
34 override;
36 // PPB_MediaStreamAudioTrack_API overrides:
37 PP_Var GetId() override;
38 PP_Bool HasEnded() override;
39 int32_t Configure(const int32_t attrib_list[],
40 scoped_refptr<TrackedCallback> callback) override;
41 int32_t GetAttrib(PP_MediaStreamAudioTrack_Attrib attrib,
42 int32_t* value) override;
43 int32_t GetBuffer(PP_Resource* buffer,
44 scoped_refptr<TrackedCallback> callback) override;
45 int32_t RecycleBuffer(PP_Resource buffer) override;
46 void Close() override;
48 // MediaStreamBufferManager::Delegate overrides:
49 void OnNewBufferEnqueued() override;
51 private:
52 PP_Resource GetAudioBuffer();
54 void ReleaseBuffers();
56 // IPC message handlers.
57 void OnPluginMsgConfigureReply(const ResourceMessageReplyParams& params);
59 // Allocated buffer resources by |GetBuffer()|.
60 typedef std::map<PP_Resource, scoped_refptr<AudioBufferResource> > BufferMap;
61 BufferMap buffers_;
63 PP_Resource* get_buffer_output_;
65 scoped_refptr<TrackedCallback> configure_callback_;
67 scoped_refptr<TrackedCallback> get_buffer_callback_;
69 DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioTrackResource);
72 } // namespace proxy
73 } // namespace ppapi
75 #endif // PPAPI_PROXY_MEDIA_STREAM_AUDIO_TRACK_RESOURCE_H_