OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef MEDIA_CAST_LOGGING_LOG_SERIALIZER_H_ | 5 #ifndef MEDIA_CAST_LOGGING_LOG_SERIALIZER_H_ |
6 #define MEDIA_CAST_LOGGING_LOG_SERIALIZER_H_ | 6 #define MEDIA_CAST_LOGGING_LOG_SERIALIZER_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 // 3. Call |GetSerializedLogAndReset()| to get the result. | 29 // 3. Call |GetSerializedLogAndReset()| to get the result. |
30 // 4. (Optional) Call |GetSerializedLengthSoFar()| between each serialize call. | 30 // 4. (Optional) Call |GetSerializedLengthSoFar()| between each serialize call. |
31 class LogSerializer { | 31 class LogSerializer { |
32 public: | 32 public: |
33 // Constructs a LogSerializer that caps size of serialized message to | 33 // Constructs a LogSerializer that caps size of serialized message to |
34 // |max_serialized_bytes|. | 34 // |max_serialized_bytes|. |
35 LogSerializer(const int max_serialized_bytes); | 35 LogSerializer(const int max_serialized_bytes); |
36 ~LogSerializer(); | 36 ~LogSerializer(); |
37 | 37 |
38 // Serialize |frame_events|, |packet_events|, |first_rtp_timestamp| | 38 // Serialize |frame_events|, |packet_events|, |first_rtp_timestamp| |
39 // returned from EncodingEventSubscriber associated with |stream_id|. | 39 // returned from EncodingEventSubscriber. |is_audio| indicates whether the |
| 40 // events are from an audio or video stream. |
40 // | 41 // |
41 // Returns |true| if serialization is successful. This function | 42 // Returns |true| if serialization is successful. This function |
42 // returns |false| if the serialized string will exceed |kMaxSerializedsize|. | 43 // returns |false| if the serialized string will exceed |kMaxSerializedsize|. |
43 // | 44 // |
44 // This may be called multiple times with different streams and events before | 45 // This may be called multiple times with different streams and events before |
45 // calling |GetSerializedString()|. | 46 // calling |GetSerializedString()|. |
46 // | 47 // |
47 // See .cc file for format specification. | 48 // See .cc file for format specification. |
48 bool SerializeEventsForStream(const int stream_id, | 49 bool SerializeEventsForStream(bool is_audio, |
49 const FrameEventMap& frame_events, | 50 const FrameEventMap& frame_events, |
50 const PacketEventMap& packet_events, | 51 const PacketEventMap& packet_events, |
51 const RtpTimestamp first_rtp_timestamp); | 52 const RtpTimestamp first_rtp_timestamp); |
52 | 53 |
53 // Gets a string of serialized events up to the last successful call to | 54 // Gets a string of serialized events up to the last successful call to |
54 // |SerializeEventsForStream()| and resets it. | 55 // |SerializeEventsForStream()| and resets it. |
55 scoped_ptr<std::string> GetSerializedLogAndReset(); | 56 scoped_ptr<std::string> GetSerializedLogAndReset(); |
56 | 57 |
57 // Returns the length of the serialized string since last | 58 // Returns the length of the serialized string since last |
58 // successful serialization / reset. | 59 // successful serialization / reset. |
59 int GetSerializedLength() const; | 60 int GetSerializedLength() const; |
60 | 61 |
61 private: | 62 private: |
62 scoped_ptr<std::string> serialized_log_so_far_; | 63 scoped_ptr<std::string> serialized_log_so_far_; |
63 int index_so_far_; | 64 int index_so_far_; |
64 const int max_serialized_bytes_; | 65 const int max_serialized_bytes_; |
65 }; | 66 }; |
66 | 67 |
67 } // namespace cast | 68 } // namespace cast |
68 } // namespace media | 69 } // namespace media |
69 | 70 |
70 #endif // MEDIA_CAST_LOGGING_LOG_SERIALIZER_H_ | 71 #endif // MEDIA_CAST_LOGGING_LOG_SERIALIZER_H_ |
OLD | NEW |