OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_FRAMER_FRAMER_H_ | 5 #ifndef MEDIA_CAST_FRAMER_FRAMER_H_ |
6 #define MEDIA_CAST_FRAMER_FRAMER_H_ | 6 #define MEDIA_CAST_FRAMER_FRAMER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/linked_ptr.h" | 11 #include "base/memory/linked_ptr.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/time/tick_clock.h" | 13 #include "base/time/tick_clock.h" |
14 #include "base/time/time.h" | 14 #include "base/time/time.h" |
15 #include "media/cast/framer/cast_message_builder.h" | 15 #include "media/cast/net/rtcp/rtcp.h" |
16 #include "media/cast/framer/frame_buffer.h" | 16 #include "media/cast/net/rtp/cast_message_builder.h" |
17 #include "media/cast/framer/frame_id_map.h" | 17 #include "media/cast/net/rtp/frame_buffer.h" |
18 #include "media/cast/rtcp/rtcp.h" | 18 #include "media/cast/net/rtp/frame_id_map.h" |
19 #include "media/cast/rtp_receiver/rtp_receiver_defines.h" | 19 #include "media/cast/net/rtp/rtp_receiver_defines.h" |
20 | 20 |
21 namespace media { | 21 namespace media { |
22 namespace cast { | 22 namespace cast { |
23 | 23 |
24 typedef std::map<uint32, linked_ptr<FrameBuffer> > FrameList; | 24 typedef std::map<uint32, linked_ptr<FrameBuffer> > FrameList; |
25 | 25 |
26 class Framer { | 26 class Framer { |
27 public: | 27 public: |
28 Framer(base::TickClock* clock, | 28 Framer(base::TickClock* clock, |
29 RtpPayloadFeedback* incoming_payload_feedback, | 29 RtpPayloadFeedback* incoming_payload_feedback, |
30 uint32 ssrc, | 30 uint32 ssrc, |
31 bool decoder_faster_than_max_frame_rate, | 31 bool decoder_faster_than_max_frame_rate, |
32 int max_unacked_frames); | 32 int max_unacked_frames); |
33 ~Framer(); | 33 ~Framer(); |
34 | 34 |
35 // Return true when receiving the last packet in a frame, creating a | 35 // Return true when receiving the last packet in a frame, creating a |
36 // complete frame. If a duplicate packet for an already complete frame is | 36 // complete frame. If a duplicate packet for an already complete frame is |
37 // received, the function returns false but sets |duplicate| to true. | 37 // received, the function returns false but sets |duplicate| to true. |
38 bool InsertPacket(const uint8* payload_data, | 38 bool InsertPacket(const uint8* payload_data, |
39 size_t payload_size, | 39 size_t payload_size, |
40 const RtpCastHeader& rtp_header, | 40 const RtpCastHeader& rtp_header, |
41 bool* duplicate); | 41 bool* duplicate); |
42 | 42 |
43 // Extracts a complete encoded frame - will only return a complete and | 43 // Extracts a complete encoded frame - will only return a complete and |
44 // decodable frame. Returns false if no such frames exist. | 44 // decodable frame. Returns false if no such frames exist. |
45 // |next_frame| will be set to true if the returned frame is the very | 45 // |next_frame| will be set to true if the returned frame is the very |
46 // next frame. |have_multiple_complete_frames| will be set to true | 46 // next frame. |have_multiple_complete_frames| will be set to true |
47 // if there are more decodadble frames available. | 47 // if there are more decodadble frames available. |
48 bool GetEncodedFrame(transport::EncodedFrame* video_frame, | 48 bool GetEncodedFrame(EncodedFrame* video_frame, |
49 bool* next_frame, | 49 bool* next_frame, |
50 bool* have_multiple_complete_frames); | 50 bool* have_multiple_complete_frames); |
51 | 51 |
52 void ReleaseFrame(uint32 frame_id); | 52 void ReleaseFrame(uint32 frame_id); |
53 | 53 |
54 // Reset framer state to original state and flush all pending buffers. | 54 // Reset framer state to original state and flush all pending buffers. |
55 void Reset(); | 55 void Reset(); |
56 bool TimeToSendNextCastMessage(base::TimeTicks* time_to_send); | 56 bool TimeToSendNextCastMessage(base::TimeTicks* time_to_send); |
57 void SendCastMessage(); | 57 void SendCastMessage(); |
58 | 58 |
59 private: | 59 private: |
60 const bool decoder_faster_than_max_frame_rate_; | 60 const bool decoder_faster_than_max_frame_rate_; |
61 FrameList frames_; | 61 FrameList frames_; |
62 FrameIdMap frame_id_map_; | 62 FrameIdMap frame_id_map_; |
63 | 63 |
64 scoped_ptr<CastMessageBuilder> cast_msg_builder_; | 64 scoped_ptr<CastMessageBuilder> cast_msg_builder_; |
65 | 65 |
66 DISALLOW_COPY_AND_ASSIGN(Framer); | 66 DISALLOW_COPY_AND_ASSIGN(Framer); |
67 }; | 67 }; |
68 | 68 |
69 } // namespace cast | 69 } // namespace cast |
70 } // namespace media | 70 } // namespace media |
71 | 71 |
72 #endif // MEDIA_CAST_FRAMER_FRAMER_H_ | 72 #endif // MEDIA_CAST_FRAMER_FRAMER_H_ |
OLD | NEW |