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

Unified Diff: media/cast/test/fake_media_source.cc

Issue 899583002: Revert of [Cast] Software encoder support for varying video frame sizes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cast/test/fake_media_source.h ('k') | media/cast/test/linux_output_window.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cast/test/fake_media_source.cc
diff --git a/media/cast/test/fake_media_source.cc b/media/cast/test/fake_media_source.cc
index f17a053f8dfaa23cbae74ae61373d62f6a3e5cb7..2742c05547c5fce34f53fa5ecb987a9c9980cd9e 100644
--- a/media/cast/test/fake_media_source.cc
+++ b/media/cast/test/fake_media_source.cc
@@ -7,7 +7,6 @@
#include "base/files/memory_mapped_file.h"
#include "base/files/scoped_file.h"
#include "base/logging.h"
-#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "media/audio/audio_parameters.h"
#include "media/base/audio_buffer.h"
@@ -33,19 +32,10 @@
static const int kAudioChannels = 2;
static const int kAudioSamplingFrequency = 48000;
-static const int kSoundFrequency = 440; // Frequency of sinusoid wave.
-static const float kSoundVolume = 0.10f;
+static const int kSoundFrequency = 1234; // Frequency of sinusoid wave.
+static const float kSoundVolume = 0.5f;
static const int kAudioFrameMs = 10; // Each audio frame is exactly 10ms.
static const int kAudioPacketsPerSecond = 1000 / kAudioFrameMs;
-
-// Bounds for variable frame size mode.
-static const int kMinFakeFrameWidth = 60;
-static const int kMinFakeFrameHeight = 34;
-static const int kStartingFakeFrameWidth = 854;
-static const int kStartingFakeFrameHeight = 480;
-static const int kMaxFakeFrameWidth = 1280;
-static const int kMaxFakeFrameHeight = 720;
-static const int kMaxFrameSizeChangeMillis = 5000;
void AVFreeFrame(AVFrame* frame) {
av_frame_free(&frame);
@@ -73,8 +63,7 @@
bool keep_frames)
: task_runner_(task_runner),
video_config_(video_config),
- keep_frames_(keep_frames),
- variable_frame_size_mode_(false),
+ keep_frames_(keep_frames),
synthetic_count_(0),
clock_(clock),
audio_frame_count_(0),
@@ -200,10 +189,6 @@
Rewind();
}
-void FakeMediaSource::SetVariableFrameSizeMode(bool enabled) {
- variable_frame_size_mode_ = enabled;
-}
-
void FakeMediaSource::Start(scoped_refptr<AudioFrameInput> audio_frame_input,
scoped_refptr<VideoFrameInput> video_frame_input) {
audio_frame_input_ = audio_frame_input;
@@ -222,8 +207,9 @@
// Send fake patterns.
task_runner_->PostTask(
FROM_HERE,
- base::Bind(&FakeMediaSource::SendNextFakeFrame,
- weak_factory_.GetWeakPtr()));
+ base::Bind(
+ &FakeMediaSource::SendNextFakeFrame,
+ base::Unretained(this)));
return;
}
@@ -242,16 +228,18 @@
static_cast<double>(audio_params_.sample_rate()) /
kAudioSamplingFrequency,
audio_params_.frames_per_buffer(),
- base::Bind(&FakeMediaSource::ProvideData, weak_factory_.GetWeakPtr())));
+ base::Bind(&FakeMediaSource::ProvideData, base::Unretained(this))));
task_runner_->PostTask(
FROM_HERE,
- base::Bind(&FakeMediaSource::SendNextFrame, weak_factory_.GetWeakPtr()));
+ base::Bind(
+ &FakeMediaSource::SendNextFrame,
+ base::Unretained(this)));
}
void FakeMediaSource::SendNextFakeFrame() {
- UpdateNextFrameSize();
+ gfx::Size size(video_config_.width, video_config_.height);
scoped_refptr<VideoFrame> video_frame =
- VideoFrame::CreateBlackFrame(current_frame_size_);
+ VideoFrame::CreateBlackFrame(size);
PopulateVideoFrame(video_frame.get(), synthetic_count_);
++synthetic_count_;
@@ -300,32 +288,6 @@
video_time - elapsed_time);
}
-void FakeMediaSource::UpdateNextFrameSize() {
- if (variable_frame_size_mode_) {
- bool update_size_change_time = false;
- if (current_frame_size_.IsEmpty()) {
- current_frame_size_ = gfx::Size(kStartingFakeFrameWidth,
- kStartingFakeFrameHeight);
- update_size_change_time = true;
- } else if (clock_->NowTicks() >= next_frame_size_change_time_) {
- current_frame_size_ = gfx::Size(
- base::RandInt(kMinFakeFrameWidth, kMaxFakeFrameWidth),
- base::RandInt(kMinFakeFrameHeight, kMaxFakeFrameHeight));
- update_size_change_time = true;
- }
-
- if (update_size_change_time) {
- next_frame_size_change_time_ = clock_->NowTicks() +
- base::TimeDelta::FromMillisecondsD(
- base::RandDouble() * kMaxFrameSizeChangeMillis);
- }
- } else {
- current_frame_size_ = gfx::Size(kStartingFakeFrameWidth,
- kStartingFakeFrameHeight);
- next_frame_size_change_time_ = base::TimeTicks();
- }
-}
-
bool FakeMediaSource::SendNextTranscodedVideo(base::TimeDelta elapsed_time) {
if (!is_transcoding_video())
return false;
@@ -334,13 +296,33 @@
if (video_frame_queue_.empty())
return false;
- const scoped_refptr<VideoFrame> video_frame = video_frame_queue_.front();
- if (elapsed_time < video_frame->timestamp())
+ scoped_refptr<VideoFrame> decoded_frame =
+ video_frame_queue_.front();
+ if (elapsed_time < decoded_frame->timestamp())
return false;
+
+ gfx::Size size(video_config_.width, video_config_.height);
+ scoped_refptr<VideoFrame> video_frame =
+ VideoFrame::CreateBlackFrame(size);
video_frame_queue_.pop();
+ media::CopyPlane(VideoFrame::kYPlane,
+ decoded_frame->data(VideoFrame::kYPlane),
+ decoded_frame->stride(VideoFrame::kYPlane),
+ decoded_frame->rows(VideoFrame::kYPlane),
+ video_frame.get());
+ media::CopyPlane(VideoFrame::kUPlane,
+ decoded_frame->data(VideoFrame::kUPlane),
+ decoded_frame->stride(VideoFrame::kUPlane),
+ decoded_frame->rows(VideoFrame::kUPlane),
+ video_frame.get());
+ media::CopyPlane(VideoFrame::kVPlane,
+ decoded_frame->data(VideoFrame::kVPlane),
+ decoded_frame->stride(VideoFrame::kVPlane),
+ decoded_frame->rows(VideoFrame::kVPlane),
+ video_frame.get());
// Use the timestamp from the file if we're transcoding.
- video_frame->set_timestamp(ScaleTimestamp(video_frame->timestamp()));
+ video_frame->set_timestamp(ScaleTimestamp(decoded_frame->timestamp()));
if (keep_frames_)
inserted_video_frame_queue_.push(video_frame);
video_frame_input_->InsertRawVideoFrame(
@@ -391,7 +373,9 @@
// Send next send.
task_runner_->PostDelayedTask(
FROM_HERE,
- base::Bind(&FakeMediaSource::SendNextFrame, weak_factory_.GetWeakPtr()),
+ base::Bind(
+ &FakeMediaSource::SendNextFrame,
+ base::Unretained(this)),
base::TimeDelta::FromMilliseconds(kAudioFrameMs));
}
« no previous file with comments | « media/cast/test/fake_media_source.h ('k') | media/cast/test/linux_output_window.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698