| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 REMOTING_PROTOCOL_RTP_READER_H_ | 5 #ifndef REMOTING_PROTOCOL_RTP_READER_H_ |
| 6 #define REMOTING_PROTOCOL_RTP_READER_H_ | 6 #define REMOTING_PROTOCOL_RTP_READER_H_ |
| 7 | 7 |
| 8 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "remoting/base/compound_buffer.h" | 9 #include "remoting/base/compound_buffer.h" |
| 10 #include "remoting/protocol/rtp_utils.h" | 10 #include "remoting/protocol/rtp_utils.h" |
| 11 #include "remoting/protocol/socket_reader_base.h" | 11 #include "remoting/protocol/socket_reader_base.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 namespace protocol { | 14 namespace protocol { |
| 15 | 15 |
| 16 class RtpPacket { | 16 class RtpPacket { |
| 17 public: | 17 public: |
| 18 RtpPacket(); | 18 RtpPacket(); |
| 19 ~RtpPacket(); | 19 ~RtpPacket(); |
| 20 | 20 |
| 21 const RtpHeader& header() const { return header_; } | 21 const RtpHeader& header() const { return header_; } |
| 22 RtpHeader* mutable_header() { return &header_; } | 22 RtpHeader* mutable_header() { return &header_; } |
| 23 |
| 24 const Vp8Descriptor& vp8_descriptor() const { return vp8_descriptor_; } |
| 25 Vp8Descriptor* mutable_vp8_descriptor() { return &vp8_descriptor_; } |
| 26 |
| 23 const CompoundBuffer& payload() const { return payload_; } | 27 const CompoundBuffer& payload() const { return payload_; } |
| 24 CompoundBuffer* mutable_payload() { return &payload_; } | 28 CompoundBuffer* mutable_payload() { return &payload_; } |
| 25 | 29 |
| 26 private: | 30 private: |
| 27 RtpHeader header_; | 31 RtpHeader header_; |
| 28 CompoundBuffer payload_; | 32 CompoundBuffer payload_; |
| 33 Vp8Descriptor vp8_descriptor_; |
| 29 }; | 34 }; |
| 30 | 35 |
| 31 class RtpReader : public SocketReaderBase { | 36 class RtpReader : public SocketReaderBase { |
| 32 public: | 37 public: |
| 33 RtpReader(); | 38 RtpReader(); |
| 34 ~RtpReader(); | 39 ~RtpReader(); |
| 35 | 40 |
| 36 // The OnMessageCallback is called whenever a new message is received. | 41 // The OnMessageCallback is called whenever a new message is received. |
| 37 // Ownership of the message is passed the callback. | 42 // Ownership of the message is passed the callback. |
| 38 typedef Callback1<const RtpPacket&>::Type OnMessageCallback; | 43 typedef Callback1<const RtpPacket*>::Type OnMessageCallback; |
| 39 | 44 |
| 40 // Initialize the reader and start reading. Must be called on the thread | 45 // Initialize the reader and start reading. Must be called on the thread |
| 41 // |socket| belongs to. The callback will be called when a new message is | 46 // |socket| belongs to. The callback will be called when a new message is |
| 42 // received. RtpReader owns |on_message_callback|, doesn't own | 47 // received. RtpReader owns |on_message_callback|, doesn't own |
| 43 // |socket|. | 48 // |socket|. |
| 44 void Init(net::Socket* socket, OnMessageCallback* on_message_callback); | 49 void Init(net::Socket* socket, OnMessageCallback* on_message_callback); |
| 45 | 50 |
| 46 protected: | 51 protected: |
| 47 virtual void OnDataReceived(net::IOBuffer* buffer, int data_size); | 52 virtual void OnDataReceived(net::IOBuffer* buffer, int data_size); |
| 48 | 53 |
| 49 private: | 54 private: |
| 50 scoped_ptr<OnMessageCallback> on_message_callback_; | 55 scoped_ptr<OnMessageCallback> on_message_callback_; |
| 51 | 56 |
| 52 DISALLOW_COPY_AND_ASSIGN(RtpReader); | 57 DISALLOW_COPY_AND_ASSIGN(RtpReader); |
| 53 }; | 58 }; |
| 54 | 59 |
| 55 } // namespace protocol | 60 } // namespace protocol |
| 56 } // namespace remoting | 61 } // namespace remoting |
| 57 | 62 |
| 58 | 63 |
| 59 #endif // REMOTING_PROTOCOL_RTP_READER_H_ | 64 #endif // REMOTING_PROTOCOL_RTP_READER_H_ |
| OLD | NEW |