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

Side by Side Diff: media/filters/test_video_decoder.h

Issue 149423: Converted remaining tests to use gmock and deleted all old mocking code. (Closed)
Patch Set: Fix again Created 11 years, 5 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 | « media/filters/ffmpeg_glue_unittest.cc ('k') | media/filters/test_video_renderer.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 (c) 2009 The Chromium Authors. All rights reserved. Use of this
2 // source code is governed by a BSD-style license that can be found in the
3 // LICENSE file.
4 //
5
6 #ifndef MEDIA_FILTERS_TEST_VIDEO_DECODER_H_
7 #define MEDIA_FILTERS_TEST_VIDEO_DECODER_H_
8
9 #include <string>
10
11 #include "media/base/buffers.h"
12 #include "media/base/factory.h"
13 #include "media/base/filters.h"
14 #include "media/base/mock_media_filters.h"
15 #include "media/base/video_frame_impl.h"
16 #include "media/filters/decoder_base.h"
17
18 namespace media {
19
20 class TestVideoDecoder : public DecoderBase<VideoDecoder, VideoFrame> {
21 public:
22 TestVideoDecoder()
23 : video_width_(0),
24 video_height_(0) {
25 }
26
27 bool OnInitialize(DemuxerStream* demuxer_stream) {
28 const MediaFormat& media_format = demuxer_stream->media_format();
29 std::string mime_type;
30 int width, height;
31 if (media_format.GetAsString(MediaFormat::kMimeType, &mime_type) &&
32 mime_type.compare(mime_type::kH264AnnexB) == 0 &&
33 media_format.GetAsInteger(MediaFormat::kWidth, &width) &&
34 media_format.GetAsInteger(MediaFormat::kHeight, &height)) {
35 video_width_ = width;
36 video_height_ = height;
37 media_format_.SetAsString(MediaFormat::kMimeType,
38 mime_type::kUncompressedVideo);
39 media_format_.SetAsInteger(MediaFormat::kWidth, width);
40 media_format_.SetAsInteger(MediaFormat::kHeight, height);
41 return true;
42 }
43 return false;
44 }
45
46 void OnDecode(Buffer* buffer) {
47 scoped_refptr<VideoFrame> frame;
48 VideoFrameImpl::CreateFrame(VideoSurface::YV12,
49 video_width_,
50 video_height_,
51 buffer->GetTimestamp(),
52 buffer->GetDuration(),
53 &frame);
54 if (frame) {
55 old_mocks::MockVideoDecoder::InitializeYV12Frame(frame, 0.5f);
56 EnqueueResult(frame);
57 } else {
58 host_->Error(PIPELINE_ERROR_OUT_OF_MEMORY);
59 }
60 }
61
62 static bool IsMediaFormatSupported(const MediaFormat& media_format) {
63 std::string mime_type;
64 return (media_format.GetAsString(MediaFormat::kMimeType, &mime_type) &&
65 mime_type == mime_type::kH264AnnexB);
66 }
67
68 private:
69 friend class scoped_refptr<TestVideoDecoder>;
70 virtual ~TestVideoDecoder() {}
71
72 size_t video_width_;
73 size_t video_height_;
74
75 DISALLOW_COPY_AND_ASSIGN(TestVideoDecoder);
76 };
77
78 } // namespace
79
80 #endif // MEDIA_FILTERS_TEST_VIDEO_DECODER_H_
OLDNEW
« no previous file with comments | « media/filters/ffmpeg_glue_unittest.cc ('k') | media/filters/test_video_renderer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698