blob: 1b18cfac5025dad46b916354d17338dbb985b73a [file] [log] [blame]
[email protected]03bf382f2014-01-16 05:49:501// 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_VIDEO_TRACK_RESOURCE_H_
6#define PPAPI_PROXY_MEDIA_STREAM_VIDEO_TRACK_RESOURCE_H_
7
avie029c4132015-12-23 06:45:228#include <stdint.h>
9
[email protected]03bf382f2014-01-16 05:49:5010#include <map>
11
avie029c4132015-12-23 06:45:2212#include "base/macros.h"
[email protected]03bf382f2014-01-16 05:49:5013#include "base/memory/ref_counted.h"
14#include "ppapi/proxy/media_stream_track_resource_base.h"
15#include "ppapi/proxy/ppapi_proxy_export.h"
16#include "ppapi/thunk/ppb_media_stream_video_track_api.h"
17
18namespace ppapi {
19namespace proxy {
20
21class VideoFrameResource;
22
23class PPAPI_PROXY_EXPORT MediaStreamVideoTrackResource
24 : public MediaStreamTrackResourceBase,
25 public thunk::PPB_MediaStreamVideoTrack_API {
26 public:
27 MediaStreamVideoTrackResource(Connection connection,
28 PP_Instance instance,
29 int pending_renderer_id,
30 const std::string& id);
31
[email protected]5294ec92014-05-05 23:36:5232 MediaStreamVideoTrackResource(Connection connection, PP_Instance instance);
33
nicke4784432015-04-23 14:01:4834 ~MediaStreamVideoTrackResource() override;
[email protected]03bf382f2014-01-16 05:49:5035
36 // Resource overrides:
nicke4784432015-04-23 14:01:4837 thunk::PPB_MediaStreamVideoTrack_API* AsPPB_MediaStreamVideoTrack_API()
38 override;
[email protected]03bf382f2014-01-16 05:49:5039
40 // PPB_MediaStreamVideoTrack_API overrides:
nicke4784432015-04-23 14:01:4841 PP_Var GetId() override;
42 PP_Bool HasEnded() override;
43 int32_t Configure(const int32_t attrib_list[],
44 scoped_refptr<TrackedCallback> callback) override;
45 int32_t GetAttrib(PP_MediaStreamVideoTrack_Attrib attrib,
46 int32_t* value) override;
47 int32_t GetFrame(PP_Resource* frame,
48 scoped_refptr<TrackedCallback> callback) override;
49 int32_t RecycleFrame(PP_Resource frame) override;
50 void Close() override;
51 int32_t GetEmptyFrame(PP_Resource* frame,
52 scoped_refptr<TrackedCallback> callback) override;
53 int32_t PutFrame(PP_Resource frame) override;
[email protected]03bf382f2014-01-16 05:49:5054
[email protected]a2c5dcd2014-02-08 03:20:1555 // MediaStreamBufferManager::Delegate overrides:
nicke4784432015-04-23 14:01:4856 void OnNewBufferEnqueued() override;
[email protected]03bf382f2014-01-16 05:49:5057
58 private:
59 PP_Resource GetVideoFrame();
60
61 void ReleaseFrames();
62
[email protected]61ebd74e2014-02-26 00:44:0563 // IPC message handlers.
[email protected]5294ec92014-05-05 23:36:5264 void OnPluginMsgConfigureReply(const ResourceMessageReplyParams& params,
65 const std::string& track_id);
[email protected]61ebd74e2014-02-26 00:44:0566
[email protected]03bf382f2014-01-16 05:49:5067 // Allocated frame resources by |GetFrame()|.
68 typedef std::map<PP_Resource, scoped_refptr<VideoFrameResource> > FrameMap;
69 FrameMap frames_;
70
71 PP_Resource* get_frame_output_;
[email protected]03bf382f2014-01-16 05:49:5072 scoped_refptr<TrackedCallback> get_frame_callback_;
73
[email protected]61ebd74e2014-02-26 00:44:0574 scoped_refptr<TrackedCallback> configure_callback_;
75
[email protected]03bf382f2014-01-16 05:49:5076 DISALLOW_COPY_AND_ASSIGN(MediaStreamVideoTrackResource);
77};
78
79} // namespace proxy
80} // namespace ppapi
81
82#endif // PPAPI_PROXY_MEDIA_STREAM_VIDEO_TRACK_RESOURCE_H_