Commit 5942fbfe authored by scherkus@chromium.org's avatar scherkus@chromium.org

Moving MockFFmpeg to its own file and some media.gyp cleanup.

Step one of having a completely mocked FFmpeg library.

Review URL: http://codereview.chromium.org/126160

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18455 0039d316-1c4b-4281-b951-d872f2087c98
parent 9f1591d6
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/base/mock_ffmpeg.h"
#include "base/logging.h"
#include "media/filters/ffmpeg_common.h"
namespace media {
MockFFmpeg* MockFFmpeg::instance_ = NULL;
// static
void MockFFmpeg::set(MockFFmpeg* instance) {
instance_ = instance;
}
// static
MockFFmpeg* MockFFmpeg::get() {
return instance_;
}
// FFmpeg stubs that delegate to the FFmpegMock instance.
extern "C" {
AVCodec* avcodec_find_decoder(enum CodecID id) {
return media::MockFFmpeg::get()->AVCodecFindDecoder(id);
}
int avcodec_open(AVCodecContext* avctx, AVCodec* codec) {
return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec);
}
int avcodec_thread_init(AVCodecContext* avctx, int threads) {
return media::MockFFmpeg::get()->AVCodecThreadInit(avctx, threads);
}
void avcodec_flush_buffers(AVCodecContext* avctx) {
NOTREACHED();
}
AVFrame* avcodec_alloc_frame() {
NOTREACHED();
return NULL;
}
int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture,
int* got_picture_ptr, AVPacket* avpkt) {
NOTREACHED();
return 0;
}
void av_init_packet(AVPacket* pkt) {
NOTREACHED();
}
} // extern "C"
} // namespace media
// Copyright (c) 2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef MEDIA_BASE_MOCK_FFMPEG_H_
#define MEDIA_BASE_MOCK_FFMPEG_H_
#include "testing/gmock/include/gmock/gmock.h"
struct AVCodec;
struct AVCodecContext;
struct AVFrame;
struct AVPacket;
enum CodecID;
namespace media {
class MockFFmpeg {
public:
MOCK_METHOD1(AVCodecFindDecoder, AVCodec*(enum CodecID id));
MOCK_METHOD2(AVCodecOpen, int(AVCodecContext* avctx, AVCodec* codec));
MOCK_METHOD2(AVCodecThreadInit, int(AVCodecContext* avctx, int threads));
// Setter/getter for the global instance of MockFFmpeg.
static void set(MockFFmpeg* instance);
static MockFFmpeg* get();
private:
static MockFFmpeg* instance_;
};
} // namespace media
#endif // MEDIA_BASE_MOCK_FFMPEG_H_
......@@ -6,11 +6,11 @@
#include "base/singleton.h"
#include "media/base/filters.h"
#include "media/base/mock_ffmpeg.h"
#include "media/base/mock_filter_host.h"
#include "media/filters/ffmpeg_common.h"
#include "media/filters/ffmpeg_interfaces.h"
#include "media/filters/ffmpeg_video_decoder.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using ::testing::Return;
......@@ -29,65 +29,8 @@ class MockDemuxerStream : public DemuxerStream, public AVStreamProvider {
MOCK_METHOD0(GetAVStream, AVStream*());
};
class MockFFmpeg {
public:
MOCK_METHOD1(AVCodecFindDecoder, AVCodec*(enum CodecID id));
MOCK_METHOD2(AVCodecOpen, int(AVCodecContext* avctx, AVCodec* codec));
MOCK_METHOD2(AVCodecThreadInit, int(AVCodecContext* avctx, int threads));
// Setter/getter for the global instance of MockFFmpeg.
static void set(MockFFmpeg* instance) {
instance_ = instance;
}
static MockFFmpeg* get() {
return instance_;
}
private:
static MockFFmpeg* instance_;
};
MockFFmpeg* MockFFmpeg::instance_ = NULL;
} // namespace media
// FFmpeg mocks to remove dependency on having the DLLs present.
extern "C" {
AVCodec* avcodec_find_decoder(enum CodecID id) {
return media::MockFFmpeg::get()->AVCodecFindDecoder(id);
}
int avcodec_open(AVCodecContext* avctx, AVCodec* codec) {
return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec);
}
int avcodec_thread_init(AVCodecContext* avctx, int threads) {
return media::MockFFmpeg::get()->AVCodecThreadInit(avctx, threads);
}
void avcodec_flush_buffers(AVCodecContext* avctx) {
NOTREACHED();
}
AVFrame* avcodec_alloc_frame() {
NOTREACHED();
return NULL;
}
int avcodec_decode_video2(AVCodecContext* avctx, AVFrame* picture,
int* got_picture_ptr, AVPacket* avpkt) {
NOTREACHED();
return 0;
}
void av_init_packet(AVPacket* pkt) {
NOTREACHED();
}
} // extern "C"
namespace media {
// Fixture class to facilitate writing tests. Takes care of setting up the
......
......@@ -57,9 +57,6 @@
'base/media.h',
'base/media_format.cc',
'base/media_format.h',
'base/mock_filter_host.h',
'base/mock_media_filters.h',
'base/mock_pipeline.h',
'base/pipeline.h',
'base/pipeline_impl.cc',
'base/pipeline_impl.h',
......@@ -150,6 +147,11 @@
'audio/mac/audio_output_mac_unittest.cc',
'audio/simple_sources_unittest.cc',
'base/data_buffer_unittest.cc',
'base/mock_ffmpeg.cc',
'base/mock_ffmpeg.h',
'base/mock_filter_host.h',
'base/mock_media_filters.h',
'base/mock_pipeline.h',
'base/pipeline_impl_unittest.cc',
'base/run_all_unittests.cc',
'base/seekable_buffer_unittest.cc',
......@@ -172,6 +174,7 @@
'../build/linux/system.gyp:gtk',
],
'sources!': [
'base/mock_ffmpeg.cc',
'filters/ffmpeg_demuxer_unittest.cc',
'filters/ffmpeg_glue_unittest.cc',
'filters/ffmpeg_video_decoder_unittest.cc',
......@@ -179,6 +182,7 @@
}],
['OS=="mac"', {
'sources!': [
'base/mock_ffmpeg.cc',
'filters/ffmpeg_demuxer_unittest.cc',
'filters/ffmpeg_glue_unittest.cc',
'filters/ffmpeg_video_decoder_unittest.cc',
......@@ -220,20 +224,20 @@
'../third_party/ffmpeg/ffmpeg.gyp:ffmpeg',
],
'sources': [
'player/list.h',
'player/mainfrm.h',
'player/movie.cc',
'player/movie.h',
'player/player_wtl.cc',
'player/player_wtl.rc',
'player/props.h',
'player/seek.h',
'player/resource.h',
'player/stdafx.h',
'player/view.h',
'player/wtl_renderer.cc',
'player/wtl_renderer.h',
],
'player/list.h',
'player/mainfrm.h',
'player/movie.cc',
'player/movie.h',
'player/player_wtl.cc',
'player/player_wtl.rc',
'player/props.h',
'player/seek.h',
'player/resource.h',
'player/stdafx.h',
'player/view.h',
'player/wtl_renderer.cc',
'player/wtl_renderer.h',
],
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment