Change output messages to make it more human readable
Also remove formatting using stream which is not recommended per Google C++ style guide. Change-Id: I3930f0a453acc0258876c08c4266dcbb13757ac8
This commit is contained in:
parent
5f3c0f7181
commit
c1a7fd9c4a
|
@ -35,9 +35,9 @@ const char kUsage[] =
|
|||
namespace media {
|
||||
|
||||
void DumpStreamInfo(const std::vector<MediaStream*>& streams) {
|
||||
std::cout << "Found " << streams.size() << " stream(s)." << std::endl;
|
||||
printf("Found %d stream(s).\n", streams.size());
|
||||
for (size_t i = 0; i < streams.size(); ++i)
|
||||
std::cout << "Stream [" << i << "] " << streams[i]->ToString() << std::endl;
|
||||
printf("Stream [%d] %s\n", i, streams[i]->info()->ToString().c_str());
|
||||
}
|
||||
|
||||
// Create and initialize encryptor source.
|
||||
|
@ -47,15 +47,15 @@ scoped_ptr<EncryptorSource> CreateEncryptorSource() {
|
|||
std::string rsa_private_key;
|
||||
if (!File::ReadFileToString(FLAGS_signing_key_path.c_str(),
|
||||
&rsa_private_key)) {
|
||||
LOG(ERROR) << "Failed to read from rsa_key_file.";
|
||||
LOG(ERROR) << "Failed to read from '" << FLAGS_signing_key_path << "'.";
|
||||
return scoped_ptr<EncryptorSource>();
|
||||
}
|
||||
|
||||
scoped_ptr<RequestSigner> signer(
|
||||
RsaRequestSigner::CreateSigner(FLAGS_signer, rsa_private_key));
|
||||
if (!signer) {
|
||||
LOG(ERROR) << "Cannot create signer object from "
|
||||
<< FLAGS_signing_key_path;
|
||||
LOG(ERROR) << "Cannot create signer object from '"
|
||||
<< FLAGS_signing_key_path << "'.";
|
||||
return scoped_ptr<EncryptorSource>();
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ bool RunPackager(const std::string& input) {
|
|||
return false;
|
||||
}
|
||||
|
||||
std::cout << "Packaging completed successfully." << std::endl;
|
||||
printf("Packaging completed successfully.\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,49 @@
|
|||
|
||||
#include "media/base/audio_stream_info.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "media/base/limits.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
namespace {
|
||||
std::string AudioCodecToString(AudioCodec audio_codec) {
|
||||
switch (audio_codec) {
|
||||
case kCodecAAC:
|
||||
return "AAC";
|
||||
case kCodecMP3:
|
||||
return "MP3";
|
||||
case kCodecPCM:
|
||||
return "PCM";
|
||||
case kCodecVorbis:
|
||||
return "Vorbis";
|
||||
case kCodecFLAC:
|
||||
return "FLAC";
|
||||
case kCodecAMR_NB:
|
||||
return "AMR_NB";
|
||||
case kCodecAMR_WB:
|
||||
return "AMR_WB";
|
||||
case kCodecPCM_MULAW:
|
||||
return "PCM_MULAW";
|
||||
case kCodecGSM_MS:
|
||||
return "GSM_MS";
|
||||
case kCodecPCM_S16BE:
|
||||
return "PCM_S16BE";
|
||||
case kCodecPCM_S24BE:
|
||||
return "PCM_S24BE";
|
||||
case kCodecOpus:
|
||||
return "Opus";
|
||||
case kCodecEAC3:
|
||||
return "EAC3";
|
||||
default:
|
||||
NOTIMPLEMENTED() << "Unknown Audio Codec: " << audio_codec;
|
||||
return "UnknownAudioCodec";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
AudioStreamInfo::AudioStreamInfo(int track_id,
|
||||
uint32 time_scale,
|
||||
uint64 duration,
|
||||
|
@ -51,13 +86,14 @@ bool AudioStreamInfo::IsValidConfig() const {
|
|||
}
|
||||
|
||||
std::string AudioStreamInfo::ToString() const {
|
||||
std::ostringstream s;
|
||||
s << "codec: " << codec_
|
||||
<< " sample_bits: " << static_cast<int>(sample_bits_)
|
||||
<< " num_channels: " << static_cast<int>(num_channels_)
|
||||
<< " sampling_frequency: " << sampling_frequency_
|
||||
<< " " << StreamInfo::ToString();
|
||||
return s.str();
|
||||
return base::StringPrintf(
|
||||
"%s codec: %s\n sample_bits: %d\n num_channels: %d\n "
|
||||
"sampling_frequency: %d\n",
|
||||
StreamInfo::ToString().c_str(),
|
||||
AudioCodecToString(codec_).c_str(),
|
||||
sample_bits_,
|
||||
num_channels_,
|
||||
sampling_frequency_);
|
||||
}
|
||||
|
||||
std::string AudioStreamInfo::GetCodecString(AudioCodec codec,
|
||||
|
|
|
@ -6,10 +6,48 @@
|
|||
|
||||
#include "media/base/status.h"
|
||||
|
||||
#include <sstream>
|
||||
#include "base/strings/stringprintf.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
namespace error {
|
||||
namespace {
|
||||
std::string ErrorCodeToString(Code error_code) {
|
||||
switch (error_code) {
|
||||
case OK:
|
||||
return "OK";
|
||||
case UNKNOWN:
|
||||
return "UNKNOWN";
|
||||
case CANCELLED:
|
||||
return "CANCELLED";
|
||||
case INVALID_ARGUMENT:
|
||||
return "INVALID_ARGUMENT";
|
||||
case UNIMPLEMENTED:
|
||||
return "UNIMPLEMENTED";
|
||||
case FILE_FAILURE:
|
||||
return "FILE_FAILURE";
|
||||
case END_OF_STREAM:
|
||||
return "END_OF_STREAM";
|
||||
case HTTP_FAILURE:
|
||||
return "HTTP_FAILURE";
|
||||
case PARSER_FAILURE:
|
||||
return "PARSER_FAILURE";
|
||||
case MUXER_FAILURE:
|
||||
return "MUXER_FAILURE";
|
||||
case FRAGMENT_FINALIZED:
|
||||
return "FRAGMENT_FINALIZED";
|
||||
case SERVER_ERROR:
|
||||
return "SERVER_ERROR";
|
||||
case INTERNAL_ERROR:
|
||||
return "INTERNAL_ERROR";
|
||||
default:
|
||||
NOTIMPLEMENTED() << "Unknown Status Code: " << error_code;
|
||||
return "UNKNOWN_STATUS";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
} // namespace error
|
||||
|
||||
const Status& Status::OK = Status(error::OK, "");
|
||||
const Status& Status::UNKNOWN = Status(error::UNKNOWN, "");
|
||||
|
||||
|
@ -17,9 +55,10 @@ std::string Status::ToString() const {
|
|||
if (error_code_ == error::OK)
|
||||
return "OK";
|
||||
|
||||
std::ostringstream string_stream;
|
||||
string_stream << error_code_ << ":" << error_message_;
|
||||
return string_stream.str();
|
||||
return base::StringPrintf("%d (%s): %s",
|
||||
error_code_,
|
||||
error::ErrorCodeToString(error_code_).c_str(),
|
||||
error_message_.c_str());
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const Status& x) {
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
#include "media/base/status.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "testing/gmock/include/gmock/gmock.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
|
@ -25,10 +24,7 @@ static void CheckStatus(const Status& s,
|
|||
} else {
|
||||
EXPECT_TRUE(!s.ok());
|
||||
EXPECT_THAT(s.ToString(), testing::HasSubstr(message));
|
||||
|
||||
std::ostringstream string_stream;
|
||||
string_stream << code << ":" << message;
|
||||
EXPECT_EQ(string_stream.str(), s.ToString());
|
||||
EXPECT_THAT(s.ToString(), testing::HasSubstr(base::UintToString(code)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "media/base/stream_info.h"
|
||||
|
||||
#include "base/logging.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
|
@ -34,15 +35,16 @@ StreamInfo::StreamInfo(StreamType stream_type,
|
|||
StreamInfo::~StreamInfo() {}
|
||||
|
||||
std::string StreamInfo::ToString() const {
|
||||
std::ostringstream s;
|
||||
s << "type: " << (stream_type_ == kStreamAudio ? "Audio" : "Video")
|
||||
<< " track_id: " << track_id_
|
||||
<< " time_scale: " << time_scale_
|
||||
<< " duration: " << duration_
|
||||
<< " codec_string: " << codec_string_
|
||||
<< " language: " << language_
|
||||
<< " is_encrypted: " << is_encrypted_;
|
||||
return s.str();
|
||||
return base::StringPrintf(
|
||||
"type: %s\n codec_string: %s\n time_scale: %d\n duration: %d "
|
||||
"(%.1f seconds)\n language: %s\n is_encrypted: %s\n",
|
||||
(stream_type_ == kStreamAudio ? "Audio" : "Video"),
|
||||
codec_string_.c_str(),
|
||||
time_scale_,
|
||||
duration_,
|
||||
static_cast<double>(duration_) / time_scale_,
|
||||
language_.c_str(),
|
||||
is_encrypted_ ? "true" : "false");
|
||||
}
|
||||
|
||||
} // namespace media
|
||||
|
|
|
@ -6,14 +6,37 @@
|
|||
|
||||
#include "media/base/video_stream_info.h"
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "base/strings/string_number_conversions.h"
|
||||
#include "base/strings/string_util.h"
|
||||
#include "base/strings/stringprintf.h"
|
||||
#include "media/base/limits.h"
|
||||
|
||||
namespace media {
|
||||
|
||||
namespace {
|
||||
std::string VideoCodecToString(VideoCodec video_codec) {
|
||||
switch (video_codec) {
|
||||
case kCodecH264:
|
||||
return "H264";
|
||||
case kCodecVC1:
|
||||
return "VC1";
|
||||
case kCodecMPEG2:
|
||||
return "MPEG2";
|
||||
case kCodecMPEG4:
|
||||
return "MPEG4";
|
||||
case kCodecTheora:
|
||||
return "Theora";
|
||||
case kCodecVP8:
|
||||
return "VP8";
|
||||
case kCodecVP9:
|
||||
return "VP9";
|
||||
default:
|
||||
NOTIMPLEMENTED() << "Unknown Video Codec: " << video_codec;
|
||||
return "UnknownVideoCodec";
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
|
||||
VideoStreamInfo::VideoStreamInfo(int track_id,
|
||||
uint32 time_scale,
|
||||
uint64 duration,
|
||||
|
@ -50,13 +73,13 @@ bool VideoStreamInfo::IsValidConfig() const {
|
|||
}
|
||||
|
||||
std::string VideoStreamInfo::ToString() const {
|
||||
std::ostringstream s;
|
||||
s << "codec: " << codec_
|
||||
<< " width: " << width_
|
||||
<< " height: " << height_
|
||||
<< " nalu_length_size_: " << static_cast<int>(nalu_length_size_)
|
||||
<< " " << StreamInfo::ToString();
|
||||
return s.str();
|
||||
return base::StringPrintf(
|
||||
"%s codec: %s\n width: %d\n height: %d\n nalu_length_size: %d\n",
|
||||
StreamInfo::ToString().c_str(),
|
||||
VideoCodecToString(codec_).c_str(),
|
||||
width_,
|
||||
height_,
|
||||
nalu_length_size_);
|
||||
}
|
||||
|
||||
std::string VideoStreamInfo::GetCodecString(VideoCodec codec,
|
||||
|
@ -74,7 +97,7 @@ std::string VideoStreamInfo::GetCodecString(VideoCodec codec,
|
|||
StringToLowerASCII(base::HexEncode(bytes, arraysize(bytes)));
|
||||
}
|
||||
default:
|
||||
NOTIMPLEMENTED() << "Codec: " << codec;
|
||||
NOTIMPLEMENTED() << "Unknown Codec: " << codec;
|
||||
return "unknown";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -123,8 +123,8 @@ bool MP4MediaParser::ParseBox(bool* err) {
|
|||
// before the head of the 'moof', so keeping this box around is sufficient.)
|
||||
return !(*err);
|
||||
} else {
|
||||
LOG(WARNING) << "Skipping unrecognized top-level box: "
|
||||
<< FourCCToString(reader->type());
|
||||
DLOG(WARNING) << "Skipping unrecognized top-level box: "
|
||||
<< FourCCToString(reader->type());
|
||||
}
|
||||
|
||||
queue_.Pop(reader->size());
|
||||
|
|
|
@ -148,8 +148,8 @@ bool TrackRunIterator::Init() {
|
|||
if (edits.size() > 1)
|
||||
DVLOG(1) << "Multi-entry edit box detected.";
|
||||
|
||||
LOG(INFO) << "Edit list with media time " << edits[0].media_time
|
||||
<< " ignored.";
|
||||
DLOG(INFO) << "Edit list with media time " << edits[0].media_time
|
||||
<< " ignored.";
|
||||
}
|
||||
|
||||
DecodingTimeIterator decoding_time(
|
||||
|
|
|
@ -296,9 +296,9 @@ TEST_P(PackagerTest, MP4MuxerMultipleSegmentsUnencrypted) {
|
|||
EXPECT_TRUE(ContentsEqual(kOutputVideo, kOutputVideo2));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(PackagerE2ETest,
|
||||
INSTANTIATE_TEST_CASE_P(PackagerEndToEnd,
|
||||
PackagerTestBasic,
|
||||
ValuesIn(kMediaFiles));
|
||||
INSTANTIATE_TEST_CASE_P(PackagerE2ETest, PackagerTest, ValuesIn(kMediaFiles));
|
||||
INSTANTIATE_TEST_CASE_P(PackagerEndToEnd, PackagerTest, ValuesIn(kMediaFiles));
|
||||
|
||||
} // namespace media
|
||||
|
|
Loading…
Reference in New Issue