OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef SERVICES_MEDIA_FRAMEWORK_OSTREAM_H_ | |
6 #define SERVICES_MEDIA_FRAMEWORK_OSTREAM_H_ | |
7 | |
8 #include <ostream> | |
9 | |
10 #include "services/media/framework/models/demand.h" | |
11 #include "services/media/framework/packet.h" | |
12 #include "services/media/framework/result.h" | |
13 #include "services/media/framework/stream_type.h" | |
14 | |
15 // | |
16 // This file declares a bunch of << operator overloads for dumping media stuff. | |
17 // Unless you want to add new operators, it's sufficient to know that you can | |
18 // just use the operators as expected, except that some of the overloads can | |
19 // produce multiple lines and therefore provide their own newlines. | |
20 // | |
21 // These operators are intended to be called after a label has been added to | |
22 // the stream with a trailing space. If the text generated by an operator is | |
23 // sufficiently short, the operator may add that text with no preamble and | |
24 // terminate it with std::endl. If the text has to be multiline, the operator | |
25 // first adds std::endl, then the multiline text with std::endl termination. | |
26 // Each line starts with begl in order to apply the appropriate indentation. | |
27 // The Indenter class is provided to adjust the identation level. Operators | |
28 // that take pointers need to handle nullptr. | |
29 // | |
30 | |
31 namespace mojo { | |
32 namespace media { | |
33 | |
34 class Indenter { | |
35 public: | |
36 static std::string by; | |
johngro
2016/01/26 01:32:39
Indenter::by could be constexpr. At the very leas
dalesat
2016/01/26 21:17:51
This stuff is for debugging. I'd rather leave it o
johngro
2016/01/27 22:35:22
So, I don't really understand xalloc/iword/pword s
dalesat
2016/01/28 18:49:15
Thanks for digging in.
| |
37 static int level; | |
38 Indenter() { level++; } | |
39 ~Indenter() { level--; } | |
40 }; | |
41 | |
42 template<class charT, class traits> std::basic_ostream<charT, traits>& | |
43 begl(std::basic_ostream<charT, traits>& os) { | |
44 for (int i = 0; i < Indenter::level; i++) { | |
45 os << Indenter::by; | |
46 } | |
47 return os; | |
48 } | |
49 | |
50 // The following overloads don't add newlines. | |
51 | |
52 std::ostream& operator<<(std::ostream& os, Result value); | |
53 std::ostream& operator<<(std::ostream& os, Demand value); | |
54 std::ostream& operator<<(std::ostream& os, const PacketPtr& value); | |
55 std::ostream& operator<<(std::ostream& os, StreamType::Scheme value); | |
56 std::ostream& operator<<(std::ostream& os, LpcmStreamType::SampleFormat value); | |
57 std::ostream& operator<<( | |
58 std::ostream& os, | |
59 CompressedAudioStreamType::AudioEncoding value); | |
60 std::ostream& operator<<( | |
61 std::ostream& os, | |
62 VideoStreamType::VideoEncoding value); | |
63 std::ostream& operator<<(std::ostream& os, VideoStreamType::VideoProfile value); | |
64 std::ostream& operator<<(std::ostream& os, VideoStreamType::PixelFormat value); | |
65 std::ostream& operator<<(std::ostream& os, VideoStreamType::ColorSpace value); | |
66 std::ostream& operator<<(std::ostream& os, const BytesPtr& value); | |
67 | |
68 template<typename T> | |
69 std::ostream& operator<<(std::ostream& os, Range<T> value) { | |
70 return os << value.min << ".." << value.max; | |
71 } | |
72 | |
73 std::ostream& operator<<(std::ostream& os, Range<bool> value); | |
74 | |
75 // The following overloads add newlines. | |
76 | |
77 std::ostream& operator<<(std::ostream& os, const StreamTypePtr& value); | |
78 std::ostream& operator<<(std::ostream& os, const StreamTypeSetPtr& value); | |
79 std::ostream& operator<<(std::ostream& os, const StreamTypesPtr& value); | |
80 std::ostream& operator<<(std::ostream& os, const StreamTypeSetsPtr& value); | |
81 | |
82 } // namespace media | |
83 } // namespace mojo | |
84 | |
85 #endif // SERVICES_MEDIA_FRAMEWORK_OSTREAM_H_ | |
OLD | NEW |