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

Unified 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, 11 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 side-by-side diff with in-line comments
Download patch
Index: services/media/framework/ostream.h
diff --git a/services/media/framework/ostream.h b/services/media/framework/ostream.h
new file mode 100644
index 0000000000000000000000000000000000000000..973510fb2231a7147b66f91ae389dfef7a28587b
--- /dev/null
+++ b/services/media/framework/ostream.h
@@ -0,0 +1,92 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef SERVICES_MEDIA_FRAMEWORK_OSTREAM_H_
+#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.
+
+#include <ostream>
+
+#include "services/media/framework/models/demand.h"
+#include "services/media/framework/packet.h"
+#include "services/media/framework/result.h"
+#include "services/media/framework/stream_type.h"
+
+//
+// This file declares a bunch of << operator overloads for dumping media stuff.
+// Unless you want to add new operators, it's sufficient to know that you can
+// just use the operators as expected, except that some of the overloads can
+// produce multiple lines and therefore provide their own newlines.
+//
+// These operators are intended to be called after a label has been added to
+// the stream with a trailing space. If the text generated by an operator is
+// sufficiently short, the operator may add that text with no preamble and
+// terminate it with std::endl. If the text has to be multiline, the operator
+// first adds std::endl, then the multiline text with std::endl termination.
+// Each line starts with begl in order to apply the appropriate indentation.
+// The Indenter class is provided to adjust the identation level. Operators
+// that take pointers need to handle nullptr.
+//
+
+namespace mojo {
+namespace media {
+
+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.
+ static int i = std::ios_base::xalloc();
+ return i;
+}
+
+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.
+ begl(std::basic_ostream<charT, traits>& os) {
+ for (int i = 0; i < os.iword(ostream_indent_index()); i++) {
+ os << " ";
+ }
+ return os;
+}
+
+inline std::ostream& indent(std::ostream& os) {
+ ++os.iword(ostream_indent_index());
+ return os;
+}
+
+inline std::ostream& outdent(std::ostream& os) {
+ --os.iword(ostream_indent_index());
+ return os;
+}
+
+// The following overloads don't add newlines.
+
+std::ostream& operator<<(std::ostream& os, Result value);
+std::ostream& operator<<(std::ostream& os, Demand value);
+std::ostream& operator<<(std::ostream& os, const PacketPtr& value);
+std::ostream& operator<<(std::ostream& os, StreamType::Scheme value);
+std::ostream& operator<<(std::ostream& os, LpcmStreamType::SampleFormat value);
+std::ostream& operator<<(
+ std::ostream& os,
+ CompressedAudioStreamType::AudioEncoding value);
+std::ostream& operator<<(
+ std::ostream& os,
+ VideoStreamType::VideoEncoding value);
+std::ostream& operator<<(std::ostream& os, VideoStreamType::VideoProfile value);
+std::ostream& operator<<(std::ostream& os, VideoStreamType::PixelFormat value);
+std::ostream& operator<<(std::ostream& os, VideoStreamType::ColorSpace value);
+std::ostream& operator<<(std::ostream& os, const BytesPtr& value);
+
+template<typename T>
+std::ostream& operator<<(std::ostream& os, Range<T> value) {
+ return os << value.min << ".." << value.max;
+}
+
+std::ostream& operator<<(std::ostream& os, Range<bool> value);
+
+// The following overloads add newlines.
jeffbrown 2016/02/02 05:35:47 likely to get confusing...
dalesat 2016/02/02 21:46:39 Acknowledged.
+
+std::ostream& operator<<(std::ostream& os, const StreamTypePtr& value);
+std::ostream& operator<<(std::ostream& os, const StreamTypeSetPtr& value);
+std::ostream& operator<<(std::ostream& os, const StreamTypesPtr& value);
+std::ostream& operator<<(std::ostream& os, const StreamTypeSetsPtr& value);
+
+} // namespace media
+} // namespace mojo
+
+#endif // SERVICES_MEDIA_FRAMEWORK_OSTREAM_H_

Powered by Google App Engine
This is Rietveld 408576698