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

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: Changed lpcm input/output to use packets for supplying frames. Some name changes. Synced to master. 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..94eaced5874fb0d65dd34e9a44891fe778c9121d
--- /dev/null
+++ b/services/media/framework/ostream.h
@@ -0,0 +1,85 @@
+// 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_
+
+#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 {
+
+class Indenter {
+ public:
+ 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.
+ static int level;
+ Indenter() { level++; }
+ ~Indenter() { level--; }
+};
+
+template<class charT, class traits> std::basic_ostream<charT, traits>&
+ begl(std::basic_ostream<charT, traits>& os) {
+ for (int i = 0; i < Indenter::level; i++) {
+ os << Indenter::by;
+ }
+ 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.
+
+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