Move test files in media/base to test directory

Also rename mpd/base/bandwidth_estimator_test.cc to
bandwidth_estimator_unittest.cc for consistency.

And remove mpd/base/simple_vod_mpd_notifier.* as they are not used
anywhere.

Change-Id: Iaeb096aef9259837a4eb356c18d5ca15f08d2376
This commit is contained in:
KongQun Yang 2014-10-09 16:33:56 -07:00
parent 8cc29520b0
commit e685dd1a73
17 changed files with 18 additions and 202 deletions

View File

@ -11,7 +11,7 @@
#include "packager/base/file_util.h" #include "packager/base/file_util.h"
#include "packager/base/memory/scoped_ptr.h" #include "packager/base/memory/scoped_ptr.h"
#include "packager/media/base/buffer_reader.h" #include "packager/media/base/buffer_reader.h"
#include "packager/media/base/status_test_util.h" #include "packager/media/base/test/status_test_util.h"
#include "packager/media/file/file.h" #include "packager/media/file/file.h"
namespace { namespace {

View File

@ -9,7 +9,7 @@
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_number_conversions.h"
#include "packager/base/strings/string_util.h" #include "packager/base/strings/string_util.h"
#include "packager/media/base/status_test_util.h" #include "packager/media/base/test/status_test_util.h"
namespace { namespace {
const char kTestUrl[] = "http://packager-test.appspot.com/http_test"; const char kTestUrl[] = "http://packager-test.appspot.com/http_test";

View File

@ -90,18 +90,18 @@
'buffer_writer_unittest.cc', 'buffer_writer_unittest.cc',
'closure_thread_unittest.cc', 'closure_thread_unittest.cc',
'container_names_unittest.cc', 'container_names_unittest.cc',
'fake_prng.cc', # For rsa_key_unittest
'fake_prng.h', # For rsa_key_unittest
'http_key_fetcher_unittest.cc', 'http_key_fetcher_unittest.cc',
'muxer_util_unittest.cc', 'muxer_util_unittest.cc',
'offset_byte_queue_unittest.cc', 'offset_byte_queue_unittest.cc',
'producer_consumer_queue_unittest.cc', 'producer_consumer_queue_unittest.cc',
'rsa_key_unittest.cc', 'rsa_key_unittest.cc',
'rsa_test_data.cc', # For rsa_key_unittest
'rsa_test_data.h', # For rsa_key_unittest
'status_test_util.h',
'status_test_util_unittest.cc', 'status_test_util_unittest.cc',
'status_unittest.cc', 'status_unittest.cc',
'test/fake_prng.cc', # For rsa_key_unittest
'test/fake_prng.h', # For rsa_key_unittest
'test/rsa_test_data.cc', # For rsa_key_unittest
'test/rsa_test_data.h', # For rsa_key_unittest
'test/status_test_util.h',
'widevine_key_source_unittest.cc', 'widevine_key_source_unittest.cc',
], ],
'dependencies': [ 'dependencies': [

View File

@ -10,7 +10,7 @@
#include "packager/base/synchronization/waitable_event.h" #include "packager/base/synchronization/waitable_event.h"
#include "packager/media/base/closure_thread.h" #include "packager/media/base/closure_thread.h"
#include "packager/media/base/producer_consumer_queue.h" #include "packager/media/base/producer_consumer_queue.h"
#include "packager/media/base/status_test_util.h" #include "packager/media/base/test/status_test_util.h"
namespace edash_packager { namespace edash_packager {
namespace { namespace {

View File

@ -9,9 +9,9 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/base/memory/scoped_ptr.h" #include "packager/base/memory/scoped_ptr.h"
#include "packager/media/base/fake_prng.h"
#include "packager/media/base/rsa_key.h" #include "packager/media/base/rsa_key.h"
#include "packager/media/base/rsa_test_data.h" #include "packager/media/base/test/fake_prng.h"
#include "packager/media/base/test/rsa_test_data.h"
namespace edash_packager { namespace edash_packager {
namespace media { namespace media {

View File

@ -6,7 +6,7 @@
#include <gtest/gtest-spi.h> #include <gtest/gtest-spi.h>
#include "packager/media/base/status_test_util.h" #include "packager/media/base/test/status_test_util.h"
namespace edash_packager { namespace edash_packager {
namespace media { namespace media {

View File

@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "packager/media/base/fake_prng.h" #include "packager/media/base/test/fake_prng.h"
#include <openssl/rand.h> #include <openssl/rand.h>

View File

@ -4,7 +4,7 @@
// license that can be found in the LICENSE file or at // license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd // https://developers.google.com/open-source/licenses/bsd
#include "packager/media/base/rsa_test_data.h" #include "packager/media/base/test/rsa_test_data.h"
#include <stdint.h> #include <stdint.h>

View File

@ -12,7 +12,7 @@
#include "packager/base/strings/stringprintf.h" #include "packager/base/strings/stringprintf.h"
#include "packager/media/base/key_fetcher.h" #include "packager/media/base/key_fetcher.h"
#include "packager/media/base/request_signer.h" #include "packager/media/base/request_signer.h"
#include "packager/media/base/status_test_util.h" #include "packager/media/base/test/status_test_util.h"
#include "packager/media/base/widevine_key_source.h" #include "packager/media/base/widevine_key_source.h"
using ::testing::_; using ::testing::_;
@ -224,7 +224,7 @@ TEST_F(WidevineKeySourceTest, HttpFetchFailure) {
kSignerName); kSignerName);
const Status kMockStatus = Status::UNKNOWN; const Status kMockStatus = Status::UNKNOWN;
EXPECT_CALL(*mock_key_fetcher_, EXPECT_CALL(*mock_key_fetcher_,
FetchKeys(kServerUrl, expected_post_data, _)) FetchKeys(StrEq(kServerUrl), expected_post_data, _))
.WillOnce(Return(kMockStatus)); .WillOnce(Return(kMockStatus));
CreateWidevineKeySource(); CreateWidevineKeySource();

View File

@ -14,8 +14,8 @@
#include "packager/media/base/key_source.h" #include "packager/media/base/key_source.h"
#include "packager/media/base/media_stream.h" #include "packager/media/base/media_stream.h"
#include "packager/media/base/muxer.h" #include "packager/media/base/muxer.h"
#include "packager/media/base/status_test_util.h"
#include "packager/media/base/stream_info.h" #include "packager/media/base/stream_info.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/formats/mp4/mp4_muxer.h" #include "packager/media/formats/mp4/mp4_muxer.h"
#include "packager/media/test/test_data_util.h" #include "packager/media/test/test_data_util.h"

View File

@ -1,106 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
#include "packager/mpd/base/simple_vod_mpd_notifier.h"
#include "packager/base/stl_util.h"
#include "packager/mpd/base/content_protection_element.h"
#include "packager/mpd/base/media_info.pb.h"
namespace edash_packager {
SimpleVodMpdNotifier::SimpleVodMpdNotifier(MpdBuilder* mpd_builder)
: mpd_builder_(mpd_builder),
video_adaptation_set_(NULL),
audio_adaptation_set_(NULL),
representation_(NULL) {
DCHECK(mpd_builder);
}
SimpleVodMpdNotifier::~SimpleVodMpdNotifier() {}
bool SimpleVodMpdNotifier::Init() {
return true;
}
bool SimpleVodMpdNotifier::NotifyNewContainer(const MediaInfo& media_info,
uint32_t* container_id) {
DCHECK(container_id);
if (media_info.video_info_size() > 0 && media_info.audio_info_size() > 0) {
LOG(ERROR) << "SimpleVodMpdNotifier cannot handle media container with "
"both video and audio";
return false;
}
ContainerType container_type = kVideo;
if (media_info.video_info_size() > 0) {
container_type = kVideo;
} else if (media_info.audio_info_size() > 0) {
container_type = kAudio;
} else {
LOG(ERROR) << "Either video_info or audio_info must be populated.";
return false;
}
if (!AddNewRepresentation(container_type, media_info, container_id))
return false;
return mpd_builder_->WriteMpd();
}
bool SimpleVodMpdNotifier::NotifyNewSegment(uint32_t container_id,
uint64_t start_time,
uint64_t duration) {
DLOG(INFO) << "VOD does not support this operation.";
return false;
}
bool SimpleVodMpdNotifier::AddContentProtectionElement(
uint32_t container_id,
const ContentProtectionElement& content_protection_element) {
if (!ContainsKey(id_to_representation_, container_id))
return false;
Representation* representation = id_to_representation_[container_id];
DCHECK(representation);
representation->AddContentProtectionElement(content_protection_element);
return mpd_builder_->WriteMpd();
}
bool SimpleVodMpdNotifier::AddNewRepresentation(ContainerType type,
const MediaInfo& media_info,
uint32_t* container_id) {
// Use pointer-pointer to set {video,audio}_adaptation_set_.
AdaptationSet** adaptation_set_pp = NULL;
if (type == kVideo) {
adaptation_set_pp = &video_adaptation_set_;
} else if (type == kAudio){
adaptation_set_pp = &audio_adaptation_set_;
} else {
NOTREACHED() << "Unknown container type: " << type;
return false;
}
if (!*adaptation_set_pp)
*adaptation_set_pp = mpd_builder_->AddAdaptationSet();
AdaptationSet* const adaptation_set = *adaptation_set_pp;
Representation* new_representation =
adaptation_set->AddRepresentation(media_info);
if (!new_representation)
return false;
const uint32_t representation_id = new_representation->id();
id_to_representation_[representation_id] = new_representation;
*container_id = representation_id;
return true;
}
} // namespace edash_packager

View File

@ -1,79 +0,0 @@
// Copyright 2014 Google Inc. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file or at
// https://developers.google.com/open-source/licenses/bsd
//
// Very simple implementation of MpdNotifier. Holds an instance of MpdBuilder
// and calls methods on the object directly.
#ifndef MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
#define MPD_BASE_SIMPLE_MPD_NOTIFIER_H_
#include "packager/mpd/base/mpd_notifier.h"
#include "packager/mpd/base/mpd_builder.h"
namespace edash_packager {
// This assumes that MpdBuilder is for VOD. This class also assumes that all the
// container is for an AdaptationSet.
class SimpleVodMpdNotifier : public MpdNotifier {
public:
// MpdBuilder must be initialized before passing a pointer to this object.
// The ownership of |mpd_builder| does not transfer to this object and it must
// be non-NULL.
explicit SimpleVodMpdNotifier(MpdBuilder* mpd_builder);
virtual ~SimpleVodMpdNotifier();
// MpdNotifier implementation.
// This should be called only once.
virtual bool Init() OVERRIDE;
// Notifies MpdBuilder to add a container. The container must have audio
// (logical exclusive) or video, IOW it cannot have both audio and video nor
// can both audio and video be empty.
// On success this writes out MPD and returns true, otherwise returns false.
virtual bool NotifyNewContainer(const MediaInfo& media_info,
uint32_t* id) OVERRIDE;
// As documented in MpdNotifier. This is Live only feature. This will return
// false.
virtual bool NotifyNewSegment(uint32_t id,
uint64_t start_time,
uint64_t duration) OVERRIDE;
// Adds content protection information to the container added via
// NotifyNewContainer(). This will fail if |id| is not a value populated by
// calling NotifyNewContainer().
// On success this writes out MPD and returns true, otherwise returns false.
virtual bool AddContentProtectionElement(
uint32_t id,
const ContentProtectionElement& content_protection_element) OVERRIDE;
private:
enum ContainerType {
kVideo,
kAudio
};
// Adds new Representation to mpd_builder_ on success.
// Sets {audio,video}_adaptation_set_ depending on |type|, if it is NULL.
bool AddNewRepresentation(ContainerType type,
const MediaInfo& media_info,
uint32_t* id);
// None of these are owned by this object.
MpdBuilder* const mpd_builder_;
AdaptationSet* audio_adaptation_set_;
AdaptationSet* video_adaptation_set_;
Representation* representation_;
std::map<uint32_t, Representation*> id_to_representation_;
DISALLOW_COPY_AND_ASSIGN(SimpleVodMpdNotifier);
};
} // namespace edash_packager
#endif // MPD_BASE_SIMPLE_MPD_NOTIFIER_H_

View File

@ -42,6 +42,7 @@
'base/mpd_notifier.h', 'base/mpd_notifier.h',
'base/mpd_utils.cc', 'base/mpd_utils.cc',
'base/mpd_utils.h', 'base/mpd_utils.h',
'base/segment_info.h',
'base/simple_mpd_notifier.cc', 'base/simple_mpd_notifier.cc',
'base/simple_mpd_notifier.h', 'base/simple_mpd_notifier.h',
'base/xml/scoped_xml_ptr.h', 'base/xml/scoped_xml_ptr.h',
@ -63,7 +64,7 @@
'target_name': 'mpd_unittest', 'target_name': 'mpd_unittest',
'type': '<(gtest_target_type)', 'type': '<(gtest_target_type)',
'sources': [ 'sources': [
'base/bandwidth_estimator_test.cc', 'base/bandwidth_estimator_unittest.cc',
'base/mpd_builder_unittest.cc', 'base/mpd_builder_unittest.cc',
'base/xml/xml_node_unittest.cc', 'base/xml/xml_node_unittest.cc',
'test/mpd_builder_test_helper.cc', 'test/mpd_builder_test_helper.cc',