Move status.h under packager/

Change-Id: I4a7f34c575c1c8b9a9a275f3889cf8641cfdd471
This commit is contained in:
KongQun Yang 2017-06-29 15:23:53 -07:00
parent e56d1faaf0
commit 3bad4ca700
49 changed files with 138 additions and 126 deletions

View File

@ -320,7 +320,7 @@ int PackagerMain(int argc, char** argv) {
stream_descriptors.push_back(stream_descriptor.value()); stream_descriptors.push_back(stream_descriptor.value());
} }
Packager packager; Packager packager;
media::Status status = Status status =
packager.Initialize(packaging_params.value(), stream_descriptors); packager.Initialize(packaging_params.value(), stream_descriptors);
if (!status.ok()) { if (!status.ok()) {
LOG(ERROR) << "Failed to initialize packager: " << status.ToString(); LOG(ERROR) << "Failed to initialize packager: " << status.ToString();

View File

@ -14,13 +14,13 @@
#include "packager/media/base/muxer_options.h" #include "packager/media/base/muxer_options.h"
#include "packager/media/base/playready_key_source.h" #include "packager/media/base/playready_key_source.h"
#include "packager/media/base/request_signer.h" #include "packager/media/base/request_signer.h"
#include "packager/media/base/status.h"
#include "packager/media/base/widevine_key_source.h" #include "packager/media/base/widevine_key_source.h"
#include "packager/media/chunking/chunking_handler.h" #include "packager/media/chunking/chunking_handler.h"
#include "packager/media/crypto/encryption_handler.h" #include "packager/media/crypto/encryption_handler.h"
#include "packager/media/file/file.h" #include "packager/media/file/file.h"
#include "packager/mpd/base/mpd_options.h" #include "packager/mpd/base/mpd_options.h"
#include "packager/packager.h" #include "packager/packager.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -29,7 +29,6 @@ namespace media {
class MediaHandler; class MediaHandler;
class KeySource; class KeySource;
class Status;
struct ChunkingOptions; struct ChunkingOptions;
struct EncryptionOptions; struct EncryptionOptions;
struct MuxerOptions; struct MuxerOptions;

View File

@ -10,7 +10,7 @@
#include <vector> #include <vector>
#include "packager/base/macros.h" #include "packager/base/macros.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -11,8 +11,8 @@
#include "packager/base/files/file_util.h" #include "packager/base/files/file_util.h"
#include "packager/media/base/buffer_reader.h" #include "packager/media/base/buffer_reader.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/file/file.h" #include "packager/media/file/file.h"
#include "packager/status_test_util.h"
namespace { namespace {
const int kReservedBufferCapacity = 1000; const int kReservedBufferCapacity = 1000;

View File

@ -9,7 +9,7 @@
#include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_number_conversions.h"
#include "packager/media/base/fixed_key_source.h" #include "packager/media/base/fixed_key_source.h"
#include "packager/media/base/test/status_test_util.h" #include "packager/status_test_util.h"
#define EXPECT_HEX_EQ(expected, actual) \ #define EXPECT_HEX_EQ(expected, actual) \
do { \ do { \

View File

@ -13,7 +13,7 @@
#include "packager/base/compiler_specific.h" #include "packager/base/compiler_specific.h"
#include "packager/media/base/key_fetcher.h" #include "packager/media/base/key_fetcher.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

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/test/status_test_util.h" #include "packager/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

@ -8,7 +8,7 @@
#define MEDIA_BASE_KEY_FETCHER_H_ #define MEDIA_BASE_KEY_FETCHER_H_
#include "base/macros.h" #include "base/macros.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -11,7 +11,7 @@
#include <vector> #include <vector>
#include "packager/media/base/protection_system_specific_info.h" #include "packager/media/base/protection_system_specific_info.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -80,8 +80,6 @@
'request_signer.h', 'request_signer.h',
'rsa_key.cc', 'rsa_key.cc',
'rsa_key.h', 'rsa_key.h',
'status.cc',
'status.h',
'stream_info.cc', 'stream_info.cc',
'stream_info.h', 'stream_info.h',
'text_sample.cc', 'text_sample.cc',
@ -100,6 +98,7 @@
'dependencies': [ 'dependencies': [
'widevine_pssh_data_proto', 'widevine_pssh_data_proto',
'../../base/base.gyp:base', '../../base/base.gyp:base',
'../../packager.gyp:status',
'../../third_party/boringssl/boringssl.gyp:boringssl', '../../third_party/boringssl/boringssl.gyp:boringssl',
'../../third_party/curl/curl.gyp:libcurl', '../../third_party/curl/curl.gyp:libcurl',
'../../third_party/libxml/libxml.gyp:libxml', '../../third_party/libxml/libxml.gyp:libxml',
@ -150,17 +149,15 @@
'protection_system_specific_info_unittest.cc', 'protection_system_specific_info_unittest.cc',
'rsa_key_unittest.cc', 'rsa_key_unittest.cc',
'status_test_util_unittest.cc', 'status_test_util_unittest.cc',
'status_unittest.cc',
'test/fake_prng.cc', # For rsa_key_unittest 'test/fake_prng.cc', # For rsa_key_unittest
'test/fake_prng.h', # 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.cc', # For rsa_key_unittest
'test/rsa_test_data.h', # 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': [
'../../testing/gtest.gyp:gtest',
'../../testing/gmock.gyp:gmock', '../../testing/gmock.gyp:gmock',
'../../testing/gtest.gyp:gtest',
'../../third_party/boringssl/boringssl.gyp:boringssl', '../../third_party/boringssl/boringssl.gyp:boringssl',
'../file/file.gyp:file', '../file/file.gyp:file',
'../test/media_test.gyp:media_test_support', '../test/media_test.gyp:media_test_support',

View File

@ -12,9 +12,9 @@
#include <utility> #include <utility>
#include "packager/media/base/media_sample.h" #include "packager/media/base/media_sample.h"
#include "packager/media/base/status.h"
#include "packager/media/base/stream_info.h" #include "packager/media/base/stream_info.h"
#include "packager/media/base/text_sample.h" #include "packager/media/base/text_sample.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -7,8 +7,8 @@
#include "packager/media/base/media_handler_test_base.h" #include "packager/media/base/media_handler_test_base.h"
#include "packager/media/base/audio_stream_info.h" #include "packager/media/base/audio_stream_info.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/base/video_stream_info.h" #include "packager/media/base/video_stream_info.h"
#include "packager/status_test_util.h"
namespace { namespace {

View File

@ -15,9 +15,9 @@
#include "packager/base/time/clock.h" #include "packager/base/time/clock.h"
#include "packager/media/base/media_handler.h" #include "packager/media/base/media_handler.h"
#include "packager/media/base/muxer_options.h" #include "packager/media/base/muxer_options.h"
#include "packager/media/base/status.h"
#include "packager/media/event/muxer_listener.h" #include "packager/media/event/muxer_listener.h"
#include "packager/media/event/progress_listener.h" #include "packager/media/event/progress_listener.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -89,7 +89,7 @@ std::vector<uint8_t> ConvertGuidEndianness(const std::vector<uint8_t>& input) {
// PlayReady PSSH Data is a PlayReady Header Object. // PlayReady PSSH Data is a PlayReady Header Object.
// Format is outlined in the following document. // Format is outlined in the following document.
// http://download.microsoft.com/download/2/3/8/238F67D9-1B8B-48D3-AB83-9C00112268B2/PlayReady%20Header%20Object%202015-08-13-FINAL-CL.PDF // http://download.microsoft.com/download/2/3/8/238F67D9-1B8B-48D3-AB83-9C00112268B2/PlayReady%20Header%20Object%202015-08-13-FINAL-CL.PDF
shaka::media::Status GeneratePlayReadyPsshData(const std::vector<uint8_t>& key_id, Status GeneratePlayReadyPsshData(const std::vector<uint8_t>& key_id,
const std::vector<uint8_t>& key, const std::vector<uint8_t>& key,
std::vector<uint8_t>* output) { std::vector<uint8_t>* output) {
CHECK(output); CHECK(output);
@ -118,7 +118,7 @@ shaka::media::Status GeneratePlayReadyPsshData(const std::vector<uint8_t>& key_i
// 'PlayReady Header Object' document. Note data is in little endian format. // 'PlayReady Header Object' document. Note data is in little endian format.
std::vector<uint16_t> record_value = std::vector<uint16_t> record_value =
std::vector<uint16_t>(playready_header.begin(), playready_header.end()); std::vector<uint16_t>(playready_header.begin(), playready_header.end());
shaka::media::BufferWriter writer_pr_record; BufferWriter writer_pr_record;
uint16_t record_type = 1; // Indicates that the record contains a rights management header. uint16_t record_type = 1; // Indicates that the record contains a rights management header.
uint16_t record_length = record_value.size() * 2; uint16_t record_length = record_value.size() * 2;
writer_pr_record.AppendInt(static_cast<uint8_t>(record_type & 0xff)); writer_pr_record.AppendInt(static_cast<uint8_t>(record_type & 0xff));
@ -133,7 +133,7 @@ shaka::media::Status GeneratePlayReadyPsshData(const std::vector<uint8_t>& key_i
// Create the PlayReady Header object. // Create the PlayReady Header object.
// Outline in section '1.PlayReady Header Objects' of // Outline in section '1.PlayReady Header Objects' of
// 'PlayReady Header Object' document. Note data is in little endian format. // 'PlayReady Header Object' document. Note data is in little endian format.
shaka::media::BufferWriter writer_pr_header_object; BufferWriter writer_pr_header_object;
uint32_t playready_header_length = writer_pr_record.Size() + 4 + 2; uint32_t playready_header_length = writer_pr_record.Size() + 4 + 2;
uint16_t record_count = 1; uint16_t record_count = 1;
writer_pr_header_object.AppendInt( writer_pr_header_object.AppendInt(
@ -152,7 +152,7 @@ shaka::media::Status GeneratePlayReadyPsshData(const std::vector<uint8_t>& key_i
*output = std::vector<uint8_t>(writer_pr_header_object.Buffer(), *output = std::vector<uint8_t>(writer_pr_header_object.Buffer(),
writer_pr_header_object.Buffer() + writer_pr_header_object.Buffer() +
writer_pr_header_object.Size()); writer_pr_header_object.Size());
return shaka::media::Status::OK; return Status::OK;
} }
} // namespace } // namespace

View File

@ -13,7 +13,7 @@
#include "packager/base/synchronization/condition_variable.h" #include "packager/base/synchronization/condition_variable.h"
#include "packager/base/synchronization/lock.h" #include "packager/base/synchronization/lock.h"
#include "packager/base/timer/elapsed_timer.h" #include "packager/base/timer/elapsed_timer.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

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/test/status_test_util.h" #include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace { namespace {

View File

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

View File

@ -1,23 +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
#ifndef MEDIA_BASE_STATUS_TEST_UTIL_H_
#define MEDIA_BASE_STATUS_TEST_UTIL_H_
#include <gtest/gtest.h>
#include "packager/media/base/status.h"
namespace shaka {
namespace media {
#define EXPECT_OK(val) EXPECT_EQ(Status::OK, (val))
#define ASSERT_OK(val) ASSERT_EQ(Status::OK, (val))
} // namespace media
} // namespace shaka
#endif // MEDIA_BASE_STATUS_TEST_UTIL_H_

View File

@ -15,8 +15,8 @@
#include "packager/media/base/fixed_key_source.h" #include "packager/media/base/fixed_key_source.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/test/status_test_util.h"
#include "packager/media/base/widevine_key_source.h" #include "packager/media/base/widevine_key_source.h"
#include "packager/status_test_util.h"
using ::testing::_; using ::testing::_;
using ::testing::Bool; using ::testing::Bool;

View File

@ -10,7 +10,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/media/base/media_handler_test_base.h" #include "packager/media/base/media_handler_test_base.h"
#include "packager/media/base/test/status_test_util.h" #include "packager/status_test_util.h"
using ::testing::ElementsAre; using ::testing::ElementsAre;
using ::testing::IsEmpty; using ::testing::IsEmpty;

View File

@ -13,9 +13,9 @@
#include "packager/media/base/aes_pattern_cryptor.h" #include "packager/media/base/aes_pattern_cryptor.h"
#include "packager/media/base/fixed_key_source.h" #include "packager/media/base/fixed_key_source.h"
#include "packager/media/base/media_handler_test_base.h" #include "packager/media/base/media_handler_test_base.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/codecs/video_slice_header_parser.h" #include "packager/media/codecs/video_slice_header_parser.h"
#include "packager/media/codecs/vpx_parser.h" #include "packager/media/codecs/vpx_parser.h"
#include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -14,7 +14,7 @@
#include "packager/base/compiler_specific.h" #include "packager/base/compiler_specific.h"
#include "packager/media/base/container_names.h" #include "packager/media/base/container_names.h"
#include "packager/media/base/media_handler.h" #include "packager/media/base/media_handler.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -11,8 +11,8 @@
#include "packager/media/base/fixed_key_source.h" #include "packager/media/base/fixed_key_source.h"
#include "packager/media/base/media_handler_test_base.h" #include "packager/media/base/media_handler_test_base.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/test/test_data_util.h" #include "packager/media/test/test_data_util.h"
#include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -9,8 +9,8 @@
#include <memory> #include <memory>
#include "packager/media/base/muxer_util.h" #include "packager/media/base/muxer_util.h"
#include "packager/media/base/status.h"
#include "packager/media/event/muxer_listener.h" #include "packager/media/event/muxer_listener.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -9,10 +9,10 @@
#include <memory> #include <memory>
#include "packager/media/base/muxer_options.h" #include "packager/media/base/muxer_options.h"
#include "packager/media/base/status.h"
#include "packager/media/file/file.h" #include "packager/media/file/file.h"
#include "packager/media/formats/mp2t/pes_packet_generator.h" #include "packager/media/formats/mp2t/pes_packet_generator.h"
#include "packager/media/formats/mp2t/ts_writer.h" #include "packager/media/formats/mp2t/ts_writer.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -8,10 +8,10 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/media/base/audio_stream_info.h" #include "packager/media/base/audio_stream_info.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/base/video_stream_info.h" #include "packager/media/base/video_stream_info.h"
#include "packager/media/event/mock_muxer_listener.h" #include "packager/media/event/mock_muxer_listener.h"
#include "packager/media/formats/mp2t/ts_segmenter.h" #include "packager/media/formats/mp2t/ts_segmenter.h"
#include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -11,7 +11,7 @@
#include <vector> #include <vector>
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -12,8 +12,8 @@
#include <vector> #include <vector>
#include "packager/media/base/fourccs.h" #include "packager/media/base/fourccs.h"
#include "packager/media/base/status.h"
#include "packager/media/formats/mp4/box_definitions.h" #include "packager/media/formats/mp4/box_definitions.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -9,7 +9,7 @@
#include <vector> #include <vector>
#include "packager/media/base/status.h" #include "packager/status.h"
#include "packager/third_party/libwebm/src/mkvmuxer.hpp" #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
namespace shaka { namespace shaka {

View File

@ -9,8 +9,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include <memory> #include <memory>
#include "packager/media/base/media_sample.h" #include "packager/media/base/media_sample.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/formats/webm/webm_constants.h" #include "packager/media/formats/webm/webm_constants.h"
#include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -10,8 +10,8 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "packager/media/base/status.h"
#include "packager/media/file/file_closer.h" #include "packager/media/file/file_closer.h"
#include "packager/status.h"
#include "packager/third_party/libwebm/src/mkvmuxer.hpp" #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
namespace shaka { namespace shaka {

View File

@ -8,9 +8,9 @@
#define MEDIA_FORMATS_WEBM_MULTI_SEGMENT_SEGMENTER_H_ #define MEDIA_FORMATS_WEBM_MULTI_SEGMENT_SEGMENTER_H_
#include <memory> #include <memory>
#include "packager/media/base/status.h"
#include "packager/media/formats/webm/mkv_writer.h" #include "packager/media/formats/webm/mkv_writer.h"
#include "packager/media/formats/webm/segmenter.h" #include "packager/media/formats/webm/segmenter.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -8,9 +8,9 @@
#define MEDIA_FORMATS_WEBM_SEGMENTER_H_ #define MEDIA_FORMATS_WEBM_SEGMENTER_H_
#include <memory> #include <memory>
#include "packager/media/base/status.h"
#include "packager/media/formats/webm/mkv_writer.h" #include "packager/media/formats/webm/mkv_writer.h"
#include "packager/media/formats/webm/seek_head.h" #include "packager/media/formats/webm/seek_head.h"
#include "packager/status.h"
#include "packager/third_party/libwebm/src/mkvmuxer.hpp" #include "packager/third_party/libwebm/src/mkvmuxer.hpp"
namespace shaka { namespace shaka {

View File

@ -11,9 +11,7 @@
#include "packager/media/base/media_sample.h" #include "packager/media/base/media_sample.h"
#include "packager/media/base/muxer_options.h" #include "packager/media/base/muxer_options.h"
#include "packager/media/base/status.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/base/video_stream_info.h" #include "packager/media/base/video_stream_info.h"
#include "packager/media/file/file_closer.h" #include "packager/media/file/file_closer.h"
#include "packager/media/file/file_test_util.h" #include "packager/media/file/file_test_util.h"
@ -21,6 +19,8 @@
#include "packager/media/formats/webm/mkv_writer.h" #include "packager/media/formats/webm/mkv_writer.h"
#include "packager/media/formats/webm/segmenter.h" #include "packager/media/formats/webm/segmenter.h"
#include "packager/media/formats/webm/webm_parser.h" #include "packager/media/formats/webm/webm_parser.h"
#include "packager/status.h"
#include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -10,8 +10,8 @@
#include "packager/media/formats/webm/segmenter.h" #include "packager/media/formats/webm/segmenter.h"
#include <memory> #include <memory>
#include "packager/media/base/status.h"
#include "packager/media/formats/webm/mkv_writer.h" #include "packager/media/formats/webm/mkv_writer.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -10,9 +10,9 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include "packager/media/base/status.h"
#include "packager/media/formats/webm/mkv_writer.h" #include "packager/media/formats/webm/mkv_writer.h"
#include "packager/media/formats/webm/single_segment_segmenter.h" #include "packager/media/formats/webm/single_segment_segmenter.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -10,10 +10,10 @@
#include <stdint.h> #include <stdint.h>
#include <list> #include <list>
#include "packager/media/base/status.h"
#include "packager/media/formats/mp4/box.h" #include "packager/media/formats/mp4/box.h"
#include "packager/media/formats/mp4/box_definitions.h" #include "packager/media/formats/mp4/box_definitions.h"
#include "packager/media/formats/webvtt/cue.h" #include "packager/media/formats/webvtt/cue.h"
#include "packager/status.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -5,7 +5,7 @@
#include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_number_conversions.h"
#include "packager/media/base/media_sample.h" #include "packager/media/base/media_sample.h"
#include "packager/media/base/test/status_test_util.h" #include "packager/status_test_util.h"
namespace shaka { namespace shaka {
namespace media { namespace media {

View File

@ -13,12 +13,12 @@
#include "packager/media/base/audio_stream_info.h" #include "packager/media/base/audio_stream_info.h"
#include "packager/media/base/key_source.h" #include "packager/media/base/key_source.h"
#include "packager/media/base/media_sample.h" #include "packager/media/base/media_sample.h"
#include "packager/media/base/status.h"
#include "packager/media/base/video_stream_info.h" #include "packager/media/base/video_stream_info.h"
#include "packager/media/codecs/aac_audio_specific_config.h" #include "packager/media/codecs/aac_audio_specific_config.h"
#include "packager/media/codecs/avc_decoder_configuration_record.h" #include "packager/media/codecs/avc_decoder_configuration_record.h"
#include "packager/media/codecs/es_descriptor.h" #include "packager/media/codecs/es_descriptor.h"
#include "packager/media/formats/mp2t/adts_header.h" #include "packager/media/formats/mp2t/adts_header.h"
#include "packager/status.h"
#define HAS_HEADER_EXTENSION(x) ((x != 0xBC) && (x != 0xBE) && (x != 0xBF) \ #define HAS_HEADER_EXTENSION(x) ((x != 0xBC) && (x != 0xBE) && (x != 0xBF) \
&& (x != 0xF0) && (x != 0xF2) && (x != 0xF8) \ && (x != 0xF0) && (x != 0xF2) && (x != 0xF8) \

View File

@ -10,8 +10,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/media/base/media_handler_test_base.h" #include "packager/media/base/media_handler_test_base.h"
#include "packager/media/base/test/status_test_util.h"
#include "packager/media/base/video_stream_info.h" #include "packager/media/base/video_stream_info.h"
#include "packager/status_test_util.h"
using ::testing::ElementsAre; using ::testing::ElementsAre;
using ::testing::IsEmpty; using ::testing::IsEmpty;

View File

@ -48,8 +48,6 @@ using media::Demuxer;
using media::EncryptionOptions; using media::EncryptionOptions;
using media::KeySource; using media::KeySource;
using media::MuxerOptions; using media::MuxerOptions;
using media::Status;
namespace error = media::error;
namespace media { namespace media {
namespace { namespace {

View File

@ -136,6 +136,38 @@
}], }],
'dependencies': ['packager'], 'dependencies': ['packager'],
}, },
{
'target_name': 'status',
'type': '<(component)',
'sources': [
'status.cc',
'status.h',
],
'dependencies': [
'base/base.gyp:base',
],
'conditions': [
['libpackager_type == "shared_library"', {
'defines': [
'SHARED_LIBRARY_BUILD',
'SHAKA_IMPLEMENTATION',
],
}],
],
},
{
'target_name': 'status_unittest',
'type': '<(gtest_target_type)',
'sources': [
'status_unittest.cc',
],
'dependencies': [
'status',
'testing/gmock.gyp:gmock',
'testing/gtest.gyp:gtest',
'testing/gtest.gyp:gtest_main',
]
},
{ {
'target_name': 'packager_builder_tests', 'target_name': 'packager_builder_tests',
'type': 'none', 'type': 'none',
@ -156,6 +188,7 @@
'media/trick_play/trick_play.gyp:trick_play_unittest', 'media/trick_play/trick_play.gyp:trick_play_unittest',
'mpd/mpd.gyp:mpd_unittest', 'mpd/mpd.gyp:mpd_unittest',
'packager_test', 'packager_test',
'status_unittest',
], ],
}, },
], ],

View File

@ -14,31 +14,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
// TODO(kqyang): Refactor status.h and move it under packager/. #include "packager/status.h"
#include "packager/media/base/status.h"
#if defined(SHARED_LIBRARY_BUILD)
#if defined(OS_WIN)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __declspec(dllexport)
#else
#define SHAKA_EXPORT __declspec(dllimport)
#endif // defined(SHAKA_IMPLEMENTATION)
#else // defined(OS_WIN)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __attribute__((visibility("default")))
#else
#define SHAKA_EXPORT
#endif
#endif // defined(OS_WIN)
#else // defined(SHARED_LIBRARY_BUILD)
#define SHAKA_EXPORT
#endif // defined(SHARED_LIBRARY_BUILD)
namespace shaka { namespace shaka {
@ -454,14 +430,14 @@ class SHAKA_EXPORT Packager {
/// @param packaging_params contains the packaging parameters. /// @param packaging_params contains the packaging parameters.
/// @param stream_descriptors a list of stream descriptors. /// @param stream_descriptors a list of stream descriptors.
/// @return OK on success, an appropriate error code on failure. /// @return OK on success, an appropriate error code on failure.
media::Status Initialize( Status Initialize(
const PackagingParams& packaging_params, const PackagingParams& packaging_params,
const std::vector<StreamDescriptor>& stream_descriptors); const std::vector<StreamDescriptor>& stream_descriptors);
/// Run the pipeline to completion (or failed / been cancelled). Note /// Run the pipeline to completion (or failed / been cancelled). Note
/// that it blocks until completion. /// that it blocks until completion.
/// @return OK on success, an appropriate error code on failure. /// @return OK on success, an appropriate error code on failure.
media::Status Run(); Status Run();
/// Cancel packaging. Note that it has to be called from another thread. /// Cancel packaging. Note that it has to be called from another thread.
void Cancel(); void Cancel();

View File

@ -15,7 +15,6 @@
namespace shaka { namespace shaka {
namespace { namespace {
using media::Status;
const char kTestFile[] = "bear-640x360.mp4"; const char kTestFile[] = "bear-640x360.mp4";
const char kOutputVideo[] = "output_video.mp4"; const char kOutputVideo[] = "output_video.mp4";
const char kOutputVideoTemplate[] = "output_video_$Number$.m4s"; const char kOutputVideoTemplate[] = "output_video_$Number$.m4s";
@ -103,17 +102,16 @@ TEST_F(PackagerTest, Version) {
TEST_F(PackagerTest, Success) { TEST_F(PackagerTest, Success) {
Packager packager; Packager packager;
ASSERT_TRUE( ASSERT_EQ(Status::OK, packager.Initialize(SetupPackagingParams(),
packager.Initialize(SetupPackagingParams(), SetupStreamDescriptors()) SetupStreamDescriptors()));
.ok()); ASSERT_EQ(Status::OK, packager.Run());
ASSERT_TRUE(packager.Run().ok());
} }
TEST_F(PackagerTest, MissingStreamDescriptors) { TEST_F(PackagerTest, MissingStreamDescriptors) {
std::vector<StreamDescriptor> stream_descriptors; std::vector<StreamDescriptor> stream_descriptors;
Packager packager; Packager packager;
auto status = packager.Initialize(SetupPackagingParams(), stream_descriptors); auto status = packager.Initialize(SetupPackagingParams(), stream_descriptors);
ASSERT_EQ(media::error::INVALID_ARGUMENT, status.error_code()); ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
} }
TEST_F(PackagerTest, MixingSegmentTemplateAndSingleSegment) { TEST_F(PackagerTest, MixingSegmentTemplateAndSingleSegment) {
@ -134,7 +132,7 @@ TEST_F(PackagerTest, MixingSegmentTemplateAndSingleSegment) {
Packager packager; Packager packager;
auto status = packager.Initialize(SetupPackagingParams(), stream_descriptors); auto status = packager.Initialize(SetupPackagingParams(), stream_descriptors);
ASSERT_EQ(media::error::INVALID_ARGUMENT, status.error_code()); ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
} }
TEST_F(PackagerTest, SegmentAlignedAndSubsegmentNotAligned) { TEST_F(PackagerTest, SegmentAlignedAndSubsegmentNotAligned) {
@ -142,9 +140,9 @@ TEST_F(PackagerTest, SegmentAlignedAndSubsegmentNotAligned) {
packaging_params.chunking_params.segment_sap_aligned = true; packaging_params.chunking_params.segment_sap_aligned = true;
packaging_params.chunking_params.subsegment_sap_aligned = false; packaging_params.chunking_params.subsegment_sap_aligned = false;
Packager packager; Packager packager;
ASSERT_TRUE( ASSERT_EQ(Status::OK,
packager.Initialize(packaging_params, SetupStreamDescriptors()).ok()); packager.Initialize(packaging_params, SetupStreamDescriptors()));
ASSERT_TRUE(packager.Run().ok()); ASSERT_EQ(Status::OK, packager.Run());
} }
TEST_F(PackagerTest, SegmentNotAlignedButSubsegmentAligned) { TEST_F(PackagerTest, SegmentNotAlignedButSubsegmentAligned) {
@ -153,7 +151,7 @@ TEST_F(PackagerTest, SegmentNotAlignedButSubsegmentAligned) {
packaging_params.chunking_params.subsegment_sap_aligned = true; packaging_params.chunking_params.subsegment_sap_aligned = true;
Packager packager; Packager packager;
auto status = packager.Initialize(packaging_params, SetupStreamDescriptors()); auto status = packager.Initialize(packaging_params, SetupStreamDescriptors());
ASSERT_EQ(media::error::INVALID_ARGUMENT, status.error_code()); ASSERT_EQ(error::INVALID_ARGUMENT, status.error_code());
} }
// TODO(kqyang): Add more tests. // TODO(kqyang): Add more tests.

View File

@ -4,13 +4,12 @@
// 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/status.h" #include "packager/status.h"
#include "packager/base/logging.h" #include "packager/base/logging.h"
#include "packager/base/strings/stringprintf.h" #include "packager/base/strings/stringprintf.h"
namespace shaka { namespace shaka {
namespace media {
namespace error { namespace error {
namespace { namespace {
@ -80,5 +79,4 @@ std::ostream& operator<<(std::ostream& os, const Status& x) {
return os; return os;
} }
} // namespace media
} // namespace shaka } // namespace shaka

View File

@ -4,14 +4,36 @@
// 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
#ifndef MEDIA_BASE_STATUS_H_ #ifndef PACKAGER_STATUS_H_
#define MEDIA_BASE_STATUS_H_ #define PACKAGER_STATUS_H_
#include <iostream> #include <iostream>
#include <string> #include <string>
#if defined(SHARED_LIBRARY_BUILD)
#if defined(OS_WIN)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __declspec(dllexport)
#else
#define SHAKA_EXPORT __declspec(dllimport)
#endif // defined(SHAKA_IMPLEMENTATION)
#else // defined(OS_WIN)
#if defined(SHAKA_IMPLEMENTATION)
#define SHAKA_EXPORT __attribute__((visibility("default")))
#else
#define SHAKA_EXPORT
#endif
#endif // defined(OS_WIN)
#else // defined(SHARED_LIBRARY_BUILD)
#define SHAKA_EXPORT
#endif // defined(SHARED_LIBRARY_BUILD)
namespace shaka { namespace shaka {
namespace media {
namespace error { namespace error {
@ -85,7 +107,7 @@ enum Code {
} // namespace error } // namespace error
class Status { class SHAKA_EXPORT Status {
public: public:
/// Creates a "successful" status. /// Creates a "successful" status.
Status() : error_code_(error::OK) {} Status() : error_code_(error::OK) {}
@ -170,9 +192,8 @@ class Status {
// generated copy constructor and assignment operator. // generated copy constructor and assignment operator.
}; };
std::ostream& operator<<(std::ostream& os, const Status& x); SHAKA_EXPORT std::ostream& operator<<(std::ostream& os, const Status& x);
} // namespace media
} // namespace shaka } // namespace shaka
#endif // MEDIA_BASE_STATUS_H_ #endif // PACKAGER_STATUS_H_

View File

@ -0,0 +1,17 @@
// 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
#ifndef PACKAGER_STATUS_TEST_UTIL_H_
#define PACKAGER_STATUS_TEST_UTIL_H_
#include <gtest/gtest.h>
#include "packager/status.h"
#define EXPECT_OK(val) EXPECT_EQ(shaka::Status::OK, (val))
#define ASSERT_OK(val) ASSERT_EQ(shaka::Status::OK, (val))
#endif // PACKAGER_STATUS_TEST_UTIL_H_

View File

@ -8,10 +8,9 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
#include "packager/base/strings/string_number_conversions.h" #include "packager/base/strings/string_number_conversions.h"
#include "packager/media/base/status.h" #include "packager/status.h"
namespace shaka { namespace shaka {
namespace media {
static void CheckStatus(const Status& s, static void CheckStatus(const Status& s,
error::Code code, error::Code code,
@ -166,5 +165,4 @@ TEST(Status, EqualsDifferentMessage) {
Status(error::UNKNOWN, "another")); Status(error::UNKNOWN, "another"));
} }
} // namespace media
} // namespace shaka } // namespace shaka