OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 std::vector<DataCodec> data_codecs_; | 59 std::vector<DataCodec> data_codecs_; |
60 rtc::scoped_ptr<rtc::Timing> timing_; | 60 rtc::scoped_ptr<rtc::Timing> timing_; |
61 }; | 61 }; |
62 | 62 |
63 // Keep track of sequence number and timestamp of an RTP stream. The | 63 // Keep track of sequence number and timestamp of an RTP stream. The |
64 // sequence number starts with a "random" value and increments. The | 64 // sequence number starts with a "random" value and increments. The |
65 // timestamp starts with a "random" value and increases monotonically | 65 // timestamp starts with a "random" value and increases monotonically |
66 // according to the clockrate. | 66 // according to the clockrate. |
67 class RtpClock { | 67 class RtpClock { |
68 public: | 68 public: |
69 RtpClock(int clockrate, uint16 first_seq_num, uint32 timestamp_offset) | 69 RtpClock(int clockrate, uint16_t first_seq_num, uint32_t timestamp_offset) |
70 : clockrate_(clockrate), | 70 : clockrate_(clockrate), |
71 last_seq_num_(first_seq_num), | 71 last_seq_num_(first_seq_num), |
72 timestamp_offset_(timestamp_offset) { | 72 timestamp_offset_(timestamp_offset) {} |
73 } | |
74 | 73 |
75 // Given the current time (in number of seconds which must be | 74 // Given the current time (in number of seconds which must be |
76 // monotonically increasing), Return the next sequence number and | 75 // monotonically increasing), Return the next sequence number and |
77 // timestamp. | 76 // timestamp. |
78 void Tick(double now, int* seq_num, uint32* timestamp); | 77 void Tick(double now, int* seq_num, uint32_t* timestamp); |
79 | 78 |
80 private: | 79 private: |
81 int clockrate_; | 80 int clockrate_; |
82 uint16 last_seq_num_; | 81 uint16_t last_seq_num_; |
83 uint32 timestamp_offset_; | 82 uint32_t timestamp_offset_; |
84 }; | 83 }; |
85 | 84 |
86 class RtpDataMediaChannel : public DataMediaChannel { | 85 class RtpDataMediaChannel : public DataMediaChannel { |
87 public: | 86 public: |
88 // Timing* Used for the RtpClock | 87 // Timing* Used for the RtpClock |
89 explicit RtpDataMediaChannel(rtc::Timing* timing); | 88 explicit RtpDataMediaChannel(rtc::Timing* timing); |
90 // Sets Timing == NULL, so you'll need to call set_timer() before | 89 // Sets Timing == NULL, so you'll need to call set_timer() before |
91 // using it. This is needed by FakeMediaEngine. | 90 // using it. This is needed by FakeMediaEngine. |
92 RtpDataMediaChannel(); | 91 RtpDataMediaChannel(); |
93 virtual ~RtpDataMediaChannel(); | 92 virtual ~RtpDataMediaChannel(); |
94 | 93 |
95 void set_timing(rtc::Timing* timing) { | 94 void set_timing(rtc::Timing* timing) { |
96 timing_ = timing; | 95 timing_ = timing; |
97 } | 96 } |
98 | 97 |
99 virtual bool SetSendParameters(const DataSendParameters& params); | 98 virtual bool SetSendParameters(const DataSendParameters& params); |
100 virtual bool SetRecvParameters(const DataRecvParameters& params); | 99 virtual bool SetRecvParameters(const DataRecvParameters& params); |
101 virtual bool AddSendStream(const StreamParams& sp); | 100 virtual bool AddSendStream(const StreamParams& sp); |
102 virtual bool RemoveSendStream(uint32 ssrc); | 101 virtual bool RemoveSendStream(uint32_t ssrc); |
103 virtual bool AddRecvStream(const StreamParams& sp); | 102 virtual bool AddRecvStream(const StreamParams& sp); |
104 virtual bool RemoveRecvStream(uint32 ssrc); | 103 virtual bool RemoveRecvStream(uint32_t ssrc); |
105 virtual bool SetSend(bool send) { | 104 virtual bool SetSend(bool send) { |
106 sending_ = send; | 105 sending_ = send; |
107 return true; | 106 return true; |
108 } | 107 } |
109 virtual bool SetReceive(bool receive) { | 108 virtual bool SetReceive(bool receive) { |
110 receiving_ = receive; | 109 receiving_ = receive; |
111 return true; | 110 return true; |
112 } | 111 } |
113 virtual void OnPacketReceived(rtc::Buffer* packet, | 112 virtual void OnPacketReceived(rtc::Buffer* packet, |
114 const rtc::PacketTime& packet_time); | 113 const rtc::PacketTime& packet_time); |
(...skipping 11 matching lines...) Expand all Loading... |
126 bool SetSendCodecs(const std::vector<DataCodec>& codecs); | 125 bool SetSendCodecs(const std::vector<DataCodec>& codecs); |
127 bool SetRecvCodecs(const std::vector<DataCodec>& codecs); | 126 bool SetRecvCodecs(const std::vector<DataCodec>& codecs); |
128 | 127 |
129 bool sending_; | 128 bool sending_; |
130 bool receiving_; | 129 bool receiving_; |
131 rtc::Timing* timing_; | 130 rtc::Timing* timing_; |
132 std::vector<DataCodec> send_codecs_; | 131 std::vector<DataCodec> send_codecs_; |
133 std::vector<DataCodec> recv_codecs_; | 132 std::vector<DataCodec> recv_codecs_; |
134 std::vector<StreamParams> send_streams_; | 133 std::vector<StreamParams> send_streams_; |
135 std::vector<StreamParams> recv_streams_; | 134 std::vector<StreamParams> recv_streams_; |
136 std::map<uint32, RtpClock*> rtp_clock_by_send_ssrc_; | 135 std::map<uint32_t, RtpClock*> rtp_clock_by_send_ssrc_; |
137 rtc::scoped_ptr<rtc::RateLimiter> send_limiter_; | 136 rtc::scoped_ptr<rtc::RateLimiter> send_limiter_; |
138 }; | 137 }; |
139 | 138 |
140 } // namespace cricket | 139 } // namespace cricket |
141 | 140 |
142 #endif // TALK_MEDIA_BASE_RTPDATAENGINE_H_ | 141 #endif // TALK_MEDIA_BASE_RTPDATAENGINE_H_ |
OLD | NEW |