2014-02-14 23:21:05 +00:00
|
|
|
// 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
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/base/status.h"
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2015-12-22 19:19:22 +00:00
|
|
|
#include "packager/base/logging.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/base/strings/stringprintf.h"
|
2013-10-11 21:44:55 +00:00
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
2013-10-11 21:44:55 +00:00
|
|
|
namespace media {
|
|
|
|
|
2014-03-05 23:15:22 +00:00
|
|
|
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";
|
2014-04-07 19:40:52 +00:00
|
|
|
case STOPPED:
|
|
|
|
return "STOPPED";
|
|
|
|
case TIME_OUT:
|
|
|
|
return "TIME_OUT";
|
2014-03-05 23:15:22 +00:00
|
|
|
default:
|
|
|
|
NOTIMPLEMENTED() << "Unknown Status Code: " << error_code;
|
|
|
|
return "UNKNOWN_STATUS";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // namespace
|
|
|
|
} // namespace error
|
|
|
|
|
2015-12-22 19:19:22 +00:00
|
|
|
const Status Status::OK = Status(error::OK, "");
|
|
|
|
const Status Status::UNKNOWN = Status(error::UNKNOWN, "");
|
2013-10-11 21:44:55 +00:00
|
|
|
|
|
|
|
std::string Status::ToString() const {
|
|
|
|
if (error_code_ == error::OK)
|
|
|
|
return "OK";
|
|
|
|
|
2014-03-05 23:15:22 +00:00
|
|
|
return base::StringPrintf("%d (%s): %s",
|
|
|
|
error_code_,
|
|
|
|
error::ErrorCodeToString(error_code_).c_str(),
|
|
|
|
error_message_.c_str());
|
2013-10-11 21:44:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
std::ostream& operator<<(std::ostream& os, const Status& x) {
|
|
|
|
os << x.ToString();
|
|
|
|
return os;
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|