| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/base/mock_ffmpeg.h" | 5 #include "media/base/mock_ffmpeg.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "media/ffmpeg/ffmpeg_common.h" | 8 #include "media/ffmpeg/ffmpeg_common.h" |
| 9 | 9 |
| 10 using ::testing::_; | 10 using ::testing::_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 EXPECT_CALL(*this, AVCodecInit()) | 33 EXPECT_CALL(*this, AVCodecInit()) |
| 34 .Times(AtMost(1)) | 34 .Times(AtMost(1)) |
| 35 .WillOnce(Return()); | 35 .WillOnce(Return()); |
| 36 EXPECT_CALL(*this, AVRegisterProtocol(_)) | 36 EXPECT_CALL(*this, AVRegisterProtocol(_)) |
| 37 .Times(AtMost(1)) | 37 .Times(AtMost(1)) |
| 38 .WillOnce(DoAll(SaveArg<0>(&protocol_), Return(0))); | 38 .WillOnce(DoAll(SaveArg<0>(&protocol_), Return(0))); |
| 39 EXPECT_CALL(*this, AVRegisterAll()) | 39 EXPECT_CALL(*this, AVRegisterAll()) |
| 40 .Times(AtMost(1)) | 40 .Times(AtMost(1)) |
| 41 .WillOnce(Return()); | 41 .WillOnce(Return()); |
| 42 } | 42 } |
| 43 // av_lockmgr_register() is also called from ~FFmpegLock(), so we expect |
| 44 // it to be called at the end. |
| 45 EXPECT_CALL(*this, AVRegisterLockManager(_)) |
| 46 .Times(AtMost(2)) |
| 47 .WillRepeatedly(Return(0)); |
| 43 } | 48 } |
| 44 | 49 |
| 45 MockFFmpeg::~MockFFmpeg() { | 50 MockFFmpeg::~MockFFmpeg() { |
| 46 CHECK(!outstanding_packets_) | 51 CHECK(!outstanding_packets_) |
| 47 << "MockFFmpeg destroyed with outstanding packets"; | 52 << "MockFFmpeg destroyed with outstanding packets"; |
| 48 } | 53 } |
| 49 | 54 |
| 50 void MockFFmpeg::inc_outstanding_packets() { | 55 void MockFFmpeg::inc_outstanding_packets() { |
| 51 ++outstanding_packets_; | 56 ++outstanding_packets_; |
| 52 } | 57 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 } | 90 } |
| 86 | 91 |
| 87 int av_register_protocol(URLProtocol* protocol) { | 92 int av_register_protocol(URLProtocol* protocol) { |
| 88 return media::MockFFmpeg::get()->AVRegisterProtocol(protocol); | 93 return media::MockFFmpeg::get()->AVRegisterProtocol(protocol); |
| 89 } | 94 } |
| 90 | 95 |
| 91 void av_register_all() { | 96 void av_register_all() { |
| 92 media::MockFFmpeg::get()->AVRegisterAll(); | 97 media::MockFFmpeg::get()->AVRegisterAll(); |
| 93 } | 98 } |
| 94 | 99 |
| 100 int av_lockmgr_register(int (*cb)(void**, enum AVLockOp)) { |
| 101 media::MockFFmpeg* mock = media::MockFFmpeg::get(); |
| 102 // Here |mock| may be NULL when this function is called from ~FFmpegGlue(). |
| 103 if (mock != NULL) { |
| 104 return mock->AVRegisterLockManager(cb); |
| 105 } else { |
| 106 return 0; |
| 107 } |
| 108 } |
| 109 |
| 95 AVCodec* avcodec_find_decoder(enum CodecID id) { | 110 AVCodec* avcodec_find_decoder(enum CodecID id) { |
| 96 return media::MockFFmpeg::get()->AVCodecFindDecoder(id); | 111 return media::MockFFmpeg::get()->AVCodecFindDecoder(id); |
| 97 } | 112 } |
| 98 | 113 |
| 99 int avcodec_open(AVCodecContext* avctx, AVCodec* codec) { | 114 int avcodec_open(AVCodecContext* avctx, AVCodec* codec) { |
| 100 return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec); | 115 return media::MockFFmpeg::get()->AVCodecOpen(avctx, codec); |
| 101 } | 116 } |
| 102 | 117 |
| 103 int avcodec_close(AVCodecContext* avctx) { | 118 int avcodec_close(AVCodecContext* avctx) { |
| 104 return media::MockFFmpeg::get()->AVCodecClose(avctx); | 119 return media::MockFFmpeg::get()->AVCodecClose(avctx); |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 media::MockFFmpeg::get()->AVLogSetLevel(level); | 220 media::MockFFmpeg::get()->AVLogSetLevel(level); |
| 206 } | 221 } |
| 207 | 222 |
| 208 void av_destruct_packet(AVPacket *pkt) { | 223 void av_destruct_packet(AVPacket *pkt) { |
| 209 media::MockFFmpeg::get()->AVDestructPacket(pkt); | 224 media::MockFFmpeg::get()->AVDestructPacket(pkt); |
| 210 } | 225 } |
| 211 | 226 |
| 212 } // extern "C" | 227 } // extern "C" |
| 213 | 228 |
| 214 } // namespace media | 229 } // namespace media |
| OLD | NEW |