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

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

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

Powered by Google App Engine
This is Rietveld 408576698