OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 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_SHARED_IMPL_MEDIA_STREAM_FRAME_BUFFER_H_ | |
6 #define PPAPI_SHARED_IMPL_MEDIA_STREAM_FRAME_BUFFER_H_ | |
7 | |
8 #include <deque> | |
9 #include <vector> | |
10 | |
11 #include "base/compiler_specific.h" | |
12 #include "base/memory/scoped_ptr.h" | |
13 #include "base/memory/shared_memory.h" | |
14 #include "ppapi/shared_impl/media_stream_frame.h" | |
15 #include "ppapi/shared_impl/ppapi_shared_export.h" | |
16 | |
17 namespace ppapi { | |
18 | |
19 class PPAPI_SHARED_EXPORT MediaStreamFrameBuffer { | |
20 public: | |
21 class Delegate { | |
22 public: | |
23 // It is called when a new frame is enqueued. | |
24 virtual void OnNewFrameEnqueued(); | |
25 }; | |
dmichael (off chromium)
2014/01/09 21:06:47
It might be simpler to just use a base::Closure fo
Peng
2014/01/10 19:14:30
I tried. It does not simplify code too much. :(
H
| |
26 | |
27 explicit MediaStreamFrameBuffer(Delegate* delegate); | |
dmichael (off chromium)
2014/01/09 21:06:47
(If you keep the Delegate class, comment about own
Peng
2014/01/10 19:14:30
Done.
| |
28 | |
29 ~MediaStreamFrameBuffer(); | |
30 | |
31 int32_t number_of_frames() const { return number_of_frames_; } | |
32 | |
33 int32_t frame_size() const { return frame_size_; } | |
34 | |
35 // Initializes shared memory for frames transmission. | |
36 bool SetFrames(int32_t number_of_frames, | |
37 int32_t frame_size, | |
38 scoped_ptr<base::SharedMemory> shm, | |
39 bool enqueue_all_frames); | |
40 | |
41 // Dequeues a frame from |frame_queue_|. | |
42 int32_t DequeueFrame(); | |
43 | |
44 // Puts a frame into |frame_queue_|. | |
45 void EnqueueFrame(int32_t index); | |
46 | |
47 // Gets a frame address for the given index. | |
48 MediaStreamFrame* GetFramePointer(int32_t index); | |
49 | |
50 private: | |
51 Delegate* delegate_; | |
52 // A queue of incoming frame indexes. | |
dmichael (off chromium)
2014/01/09 21:06:47
Can you elaborate more? It's not obvious what "inc
Peng
2014/01/10 19:14:30
I added a class level document. Done
| |
53 // For the input side, they are empty frames which will be filled with data | |
54 // and sent to the output side. | |
55 // For the output side, they are received frames waiting for consuming. | |
56 std::deque<int32_t> frame_queue_; | |
57 | |
58 // A vector of frame pointers. It is used for index to pointer converting. | |
59 std::vector<MediaStreamFrame*> frames_; | |
60 | |
61 // The frame size in bytes. | |
62 int32_t frame_size_; | |
63 | |
64 // The number of frames in the shared memory. | |
65 int32_t number_of_frames_; | |
66 | |
67 // A memory block shared between renderer and plugin processes. | |
68 scoped_ptr<base::SharedMemory> shm_; | |
69 | |
70 DISALLOW_COPY_AND_ASSIGN(MediaStreamFrameBuffer); | |
71 }; | |
72 | |
73 } // namespace ppapi | |
74 | |
75 #endif // PPAPI_SHAERD_IMPL_MEDIA_STREAM_FRAME_BUFFER_H_ | |
OLD | NEW |