Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(388)

Side by Side Diff: services/media/framework/ostream.h

Issue 1577953002: Motown in-proc streaming framework used to implement media services. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Sync, updates based on feedback, some functions declared const. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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_
jeffbrown 2016/02/02 05:35:47 I've started calling files like this "formatting.h
dalesat 2016/02/02 21:46:39 Done.
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 inline int ostream_indent_index() {
jeffbrown 2016/02/02 05:35:47 Don't need inline keyword. And in particular, thi
dalesat 2016/02/02 21:46:39 Done.
35 static int i = std::ios_base::xalloc();
36 return i;
37 }
38
39 template<class charT, class traits> std::basic_ostream<charT, traits>&
jeffbrown 2016/02/02 05:35:47 I think this can be specialized to ostream.
dalesat 2016/02/02 21:46:39 Done.
40 begl(std::basic_ostream<charT, traits>& os) {
41 for (int i = 0; i < os.iword(ostream_indent_index()); i++) {
42 os << " ";
43 }
44 return os;
45 }
46
47 inline std::ostream& indent(std::ostream& os) {
48 ++os.iword(ostream_indent_index());
49 return os;
50 }
51
52 inline std::ostream& outdent(std::ostream& os) {
53 --os.iword(ostream_indent_index());
54 return os;
55 }
56
57 // The following overloads don't add newlines.
58
59 std::ostream& operator<<(std::ostream& os, Result value);
60 std::ostream& operator<<(std::ostream& os, Demand value);
61 std::ostream& operator<<(std::ostream& os, const PacketPtr& value);
62 std::ostream& operator<<(std::ostream& os, StreamType::Scheme value);
63 std::ostream& operator<<(std::ostream& os, LpcmStreamType::SampleFormat value);
64 std::ostream& operator<<(
65 std::ostream& os,
66 CompressedAudioStreamType::AudioEncoding value);
67 std::ostream& operator<<(
68 std::ostream& os,
69 VideoStreamType::VideoEncoding value);
70 std::ostream& operator<<(std::ostream& os, VideoStreamType::VideoProfile value);
71 std::ostream& operator<<(std::ostream& os, VideoStreamType::PixelFormat value);
72 std::ostream& operator<<(std::ostream& os, VideoStreamType::ColorSpace value);
73 std::ostream& operator<<(std::ostream& os, const BytesPtr& value);
74
75 template<typename T>
76 std::ostream& operator<<(std::ostream& os, Range<T> value) {
77 return os << value.min << ".." << value.max;
78 }
79
80 std::ostream& operator<<(std::ostream& os, Range<bool> value);
81
82 // The following overloads add newlines.
jeffbrown 2016/02/02 05:35:47 likely to get confusing...
dalesat 2016/02/02 21:46:39 Acknowledged.
83
84 std::ostream& operator<<(std::ostream& os, const StreamTypePtr& value);
85 std::ostream& operator<<(std::ostream& os, const StreamTypeSetPtr& value);
86 std::ostream& operator<<(std::ostream& os, const StreamTypesPtr& value);
87 std::ostream& operator<<(std::ostream& os, const StreamTypeSetsPtr& value);
88
89 } // namespace media
90 } // namespace mojo
91
92 #endif // SERVICES_MEDIA_FRAMEWORK_OSTREAM_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698