Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: ppapi/shared_impl/media_stream_frame_buffer.cc

Issue 142023008: [PPAPI][MediaStream] Rename AudioFrame to AudioBuffer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix review issues Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ppapi/shared_impl/media_stream_frame_buffer.h ('k') | ppapi/thunk/ppb_audio_frame_api.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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 #include "ppapi/shared_impl/media_stream_frame_buffer.h"
6
7 #include "base/logging.h"
8 #include "ppapi/c/pp_errors.h"
9
10 namespace ppapi {
11
12 MediaStreamFrameBuffer::Delegate::~Delegate() {}
13
14 void MediaStreamFrameBuffer::Delegate::OnNewFrameEnqueued() {
15 }
16
17 MediaStreamFrameBuffer::MediaStreamFrameBuffer(Delegate* delegate)
18 : delegate_(delegate),
19 frame_size_(0),
20 number_of_frames_(0) {
21 DCHECK(delegate_);
22 }
23
24 MediaStreamFrameBuffer::~MediaStreamFrameBuffer() {
25 }
26
27 bool MediaStreamFrameBuffer::SetFrames(
28 int32_t number_of_frames,
29 int32_t frame_size,
30 scoped_ptr<base::SharedMemory> shm,
31 bool enqueue_all_frames) {
32 DCHECK(shm);
33 DCHECK(!shm_);
34 DCHECK_GT(number_of_frames, 0);
35 DCHECK_GT(frame_size, static_cast<int32_t>(sizeof(MediaStreamFrame::Header)));
36 DCHECK_EQ(frame_size & 0x3, 0);
37
38 number_of_frames_ = number_of_frames;
39 frame_size_ = frame_size;
40
41 int32_t size = number_of_frames_ * frame_size;
42 shm_ = shm.Pass();
43 if (!shm_->Map(size))
44 return false;
45
46 uint8_t* p = reinterpret_cast<uint8_t*>(shm_->memory());
47 for (int32_t i = 0; i < number_of_frames; ++i) {
48 if (enqueue_all_frames)
49 frame_queue_.push_back(i);
50 frames_.push_back(reinterpret_cast<MediaStreamFrame*>(p));
51 p += frame_size_;
52 }
53 return true;
54 }
55
56 int32_t MediaStreamFrameBuffer::DequeueFrame() {
57 if (frame_queue_.empty())
58 return PP_ERROR_FAILED;
59 int32_t frame = frame_queue_.front();
60 frame_queue_.pop_front();
61 return frame;
62 }
63
64 void MediaStreamFrameBuffer::EnqueueFrame(int32_t index) {
65 DCHECK_GE(index, 0);
66 DCHECK_LT(index, number_of_frames_);
67 frame_queue_.push_back(index);
68 delegate_->OnNewFrameEnqueued();
69 }
70
71 MediaStreamFrame* MediaStreamFrameBuffer::GetFramePointer(
72 int32_t index) {
73 DCHECK_GE(index, 0);
74 DCHECK_LT(index, number_of_frames_);
75 return frames_[index];
76 }
77
78 } // namespace ppapi
OLDNEW
« no previous file with comments | « ppapi/shared_impl/media_stream_frame_buffer.h ('k') | ppapi/thunk/ppb_audio_frame_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698