Ignore title parameter for navigator.registerProtocolHandler
[chromium-blink-merge.git] / media / cast / framer / framer.h
blobeb67064a40ab594dd25b6064d6e1bb0691e4d3f8
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
3 // found in the LICENSE file.
5 #ifndef MEDIA_CAST_FRAMER_FRAMER_H_
6 #define MEDIA_CAST_FRAMER_FRAMER_H_
8 #include <map>
10 #include "base/basictypes.h"
11 #include "base/memory/linked_ptr.h"
12 #include "base/memory/scoped_ptr.h"
13 #include "base/time/tick_clock.h"
14 #include "base/time/time.h"
15 #include "media/cast/framer/cast_message_builder.h"
16 #include "media/cast/framer/frame_buffer.h"
17 #include "media/cast/framer/frame_id_map.h"
18 #include "media/cast/rtcp/rtcp.h"
19 #include "media/cast/rtp_receiver/rtp_receiver_defines.h"
21 namespace media {
22 namespace cast {
24 typedef std::map<uint32, linked_ptr<FrameBuffer> > FrameList;
26 class Framer {
27 public:
28 Framer(base::TickClock* clock,
29 RtpPayloadFeedback* incoming_payload_feedback,
30 uint32 ssrc,
31 bool decoder_faster_than_max_frame_rate,
32 int max_unacked_frames);
33 ~Framer();
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
37 // received, the function returns false but sets |duplicate| to true.
38 bool InsertPacket(const uint8* payload_data,
39 size_t payload_size,
40 const RtpCastHeader& rtp_header,
41 bool* duplicate);
43 // Extracts a complete encoded frame - will only return a complete continuous
44 // frame.
45 // Returns false if the frame does not exist or if the frame is not complete
46 // within the given time frame.
47 bool GetEncodedVideoFrame(transport::EncodedVideoFrame* video_frame,
48 bool* next_frame);
50 bool GetEncodedAudioFrame(transport::EncodedAudioFrame* audio_frame,
51 bool* next_frame);
53 void ReleaseFrame(uint32 frame_id);
55 // Reset framer state to original state and flush all pending buffers.
56 void Reset();
57 bool TimeToSendNextCastMessage(base::TimeTicks* time_to_send);
58 void SendCastMessage();
60 private:
61 const bool decoder_faster_than_max_frame_rate_;
62 FrameList frames_;
63 FrameIdMap frame_id_map_;
65 scoped_ptr<CastMessageBuilder> cast_msg_builder_;
67 DISALLOW_COPY_AND_ASSIGN(Framer);
70 } // namespace cast
71 } // namespace media
73 #endif // MEDIA_CAST_FRAMER_FRAMER_H_