Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / ppapi / proxy / media_stream_audio_track_resource.h
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.
4
5 #ifndef PPAPI_PROXY_MEDIA_STREAM_AUDIO_TRACK_RESOURCE_H_
6 #define PPAPI_PROXY_MEDIA_STREAM_AUDIO_TRACK_RESOURCE_H_
7
8 #include <map>
9
10 #include "base/memory/ref_counted.h"
11 #include "ppapi/proxy/media_stream_track_resource_base.h"
12 #include "ppapi/proxy/ppapi_proxy_export.h"
13 #include "ppapi/thunk/ppb_media_stream_audio_track_api.h"
14
15 namespace ppapi {
16 namespace proxy {
17
18 class AudioBufferResource;
19
20 class PPAPI_PROXY_EXPORT MediaStreamAudioTrackResource
21     : public MediaStreamTrackResourceBase,
22       public thunk::PPB_MediaStreamAudioTrack_API {
23  public:
24   MediaStreamAudioTrackResource(Connection connection,
25                                 PP_Instance instance,
26                                 int pending_renderer_id,
27                                 const std::string& id);
28
29   virtual ~MediaStreamAudioTrackResource();
30
31   // Resource overrides:
32   virtual thunk::PPB_MediaStreamAudioTrack_API*
33   AsPPB_MediaStreamAudioTrack_API() OVERRIDE;
34
35   // PPB_MediaStreamAudioTrack_API overrides:
36   virtual PP_Var GetId() OVERRIDE;
37   virtual PP_Bool HasEnded() OVERRIDE;
38   virtual int32_t Configure(const int32_t attrib_list[],
39                             scoped_refptr<TrackedCallback> callback) OVERRIDE;
40   virtual int32_t GetAttrib(PP_MediaStreamAudioTrack_Attrib attrib,
41                             int32_t* value) OVERRIDE;
42   virtual int32_t GetBuffer(
43       PP_Resource* buffer,
44       scoped_refptr<TrackedCallback> callback) OVERRIDE;
45   virtual int32_t RecycleBuffer(PP_Resource buffer) OVERRIDE;
46   virtual void Close() OVERRIDE;
47
48   // MediaStreamBufferManager::Delegate overrides:
49   virtual void OnNewBufferEnqueued() OVERRIDE;
50
51  private:
52   PP_Resource GetAudioBuffer();
53
54   void ReleaseBuffers();
55
56   // Allocated buffer resources by |GetBuffer()|.
57   typedef std::map<PP_Resource, scoped_refptr<AudioBufferResource> > BufferMap;
58   BufferMap buffers_;
59
60   PP_Resource* get_buffer_output_;
61
62   scoped_refptr<TrackedCallback> get_buffer_callback_;
63
64   DISALLOW_COPY_AND_ASSIGN(MediaStreamAudioTrackResource);
65 };
66
67 }  // namespace proxy
68 }  // namespace ppapi
69
70 #endif  // PPAPI_PROXY_MEDIA_STREAM_AUDIO_TRACK_RESOURCE_H_