DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
status.cc
1 // Copyright 2014 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #include "packager/media/base/status.h"
8 
9 #include "packager/base/logging.h"
10 #include "packager/base/strings/stringprintf.h"
11 
12 namespace shaka {
13 namespace media {
14 
15 namespace error {
16 namespace {
17 std::string ErrorCodeToString(Code error_code) {
18  switch (error_code) {
19  case OK:
20  return "OK";
21  case UNKNOWN:
22  return "UNKNOWN";
23  case CANCELLED:
24  return "CANCELLED";
25  case INVALID_ARGUMENT:
26  return "INVALID_ARGUMENT";
27  case UNIMPLEMENTED:
28  return "UNIMPLEMENTED";
29  case FILE_FAILURE:
30  return "FILE_FAILURE";
31  case END_OF_STREAM:
32  return "END_OF_STREAM";
33  case HTTP_FAILURE:
34  return "HTTP_FAILURE";
35  case PARSER_FAILURE:
36  return "PARSER_FAILURE";
37  case MUXER_FAILURE:
38  return "MUXER_FAILURE";
39  case FRAGMENT_FINALIZED:
40  return "FRAGMENT_FINALIZED";
41  case SERVER_ERROR:
42  return "SERVER_ERROR";
43  case INTERNAL_ERROR:
44  return "INTERNAL_ERROR";
45  case STOPPED:
46  return "STOPPED";
47  case TIME_OUT:
48  return "TIME_OUT";
49  default:
50  NOTIMPLEMENTED() << "Unknown Status Code: " << error_code;
51  return "UNKNOWN_STATUS";
52  }
53 }
54 } // namespace
55 } // namespace error
56 
57 const Status Status::OK = Status(error::OK, "");
58 const Status Status::UNKNOWN = Status(error::UNKNOWN, "");
59 
60 std::string Status::ToString() const {
61  if (error_code_ == error::OK)
62  return "OK";
63 
64  return base::StringPrintf("%d (%s): %s",
65  error_code_,
66  error::ErrorCodeToString(error_code_).c_str(),
67  error_message_.c_str());
68 }
69 
70 std::ostream& operator<<(std::ostream& os, const Status& x) {
71  os << x.ToString();
72  return os;
73 }
74 
75 } // namespace media
76 } // namespace shaka
std::string ToString() const
Definition: status.cc:60