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

Side by Side Diff: media/filters/fake_demuxer_stream.cc

Issue 16274005: Separate DemuxerStream and VideoDecoder. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: VideoFrameStream ready for review. Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/filters/fake_demuxer_stream.h" 5 #include "media/filters/fake_demuxer_stream.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/pickle.h"
13 #include "media/base/bind_to_loop.h" 12 #include "media/base/bind_to_loop.h"
14 #include "media/base/decoder_buffer.h" 13 #include "media/base/decoder_buffer.h"
15 #include "media/base/video_frame.h" 14 #include "media/base/video_frame.h"
16 #include "ui/gfx/rect.h" 15 #include "ui/gfx/rect.h"
17 #include "ui/gfx/size.h" 16 #include "ui/gfx/size.h"
18 17
19 namespace media { 18 namespace media {
20 19
21 static const int kStartTimestampMs = 0; 20 static const int kStartTimestampMs = 0;
22 static const int kDurationMs = 30; 21 static const int kDurationMs = 30;
23 static const int kStartWidth = 320; 22 static const int kStartWidth = 320;
24 static const int kStartHeight = 240; 23 static const int kStartHeight = 240;
25 static const int kWidthDelta = 4; 24 static const int kWidthDelta = 4;
26 static const int kHeightDelta = 3; 25 static const int kHeightDelta = 3;
27 static const char kFakeBufferHeader[] = "Fake Buffer";
28 26
29 FakeDemuxerStream::FakeDemuxerStream(int num_configs, 27 FakeDemuxerStream::FakeDemuxerStream(int num_configs,
30 int num_buffers_in_one_config, 28 int num_buffers_in_one_config,
31 bool is_encrypted) 29 bool is_encrypted)
32 : message_loop_(base::MessageLoopProxy::current()), 30 : message_loop_(base::MessageLoopProxy::current()),
33 num_configs_left_(num_configs), 31 num_configs_left_(num_configs),
34 num_buffers_in_one_config_(num_buffers_in_one_config), 32 num_buffers_in_one_config_(num_buffers_in_one_config),
35 is_encrypted_(is_encrypted), 33 is_encrypted_(is_encrypted),
36 num_buffers_left_in_current_config_(num_buffers_in_one_config), 34 num_buffers_left_in_current_config_(num_buffers_in_one_config),
37 num_buffers_returned_(0), 35 num_buffers_returned_(0),
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 return; 130 return;
133 } 131 }
134 132
135 // Config change. 133 // Config change.
136 num_buffers_left_in_current_config_ = num_buffers_in_one_config_; 134 num_buffers_left_in_current_config_ = num_buffers_in_one_config_;
137 UpdateVideoDecoderConfig(); 135 UpdateVideoDecoderConfig();
138 base::ResetAndReturn(&read_cb_).Run(kConfigChanged, NULL); 136 base::ResetAndReturn(&read_cb_).Run(kConfigChanged, NULL);
139 return; 137 return;
140 } 138 }
141 139
142 // Prepare the next buffer. 140 scoped_refptr<DecoderBuffer> buffer =
143 Pickle pickle; 141 DecoderBuffer::CreateFakeVideoBufferForTest(
144 pickle.WriteString(kFakeBufferHeader); 142 video_decoder_config_, current_timestamp_, duration_);
145 pickle.WriteInt(video_decoder_config_.coded_size().width());
146 pickle.WriteInt(video_decoder_config_.coded_size().height());
147 pickle.WriteInt64(current_timestamp_.InMilliseconds());
148
149 scoped_refptr<DecoderBuffer> buffer = DecoderBuffer::CopyFrom(
150 static_cast<const uint8*>(pickle.data()), pickle.size());
151 143
152 // TODO(xhwang): Output out-of-order buffers if needed. 144 // TODO(xhwang): Output out-of-order buffers if needed.
153 buffer->SetTimestamp(current_timestamp_);
154 buffer->SetDuration(duration_);
155 current_timestamp_ += duration_; 145 current_timestamp_ += duration_;
156 146
157 num_buffers_left_in_current_config_--; 147 num_buffers_left_in_current_config_--;
158 if (num_buffers_left_in_current_config_ == 0) 148 if (num_buffers_left_in_current_config_ == 0)
159 num_configs_left_--; 149 num_configs_left_--;
160 150
161 num_buffers_returned_++; 151 num_buffers_returned_++;
162 base::ResetAndReturn(&read_cb_).Run(kOk, buffer); 152 base::ResetAndReturn(&read_cb_).Run(kOk, buffer);
163 } 153 }
164 154
165 } // namespace media 155 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698