Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Unified Diff: webrtc/media/base/rtpdataengine.cc

Issue 2541583003: RtpDataEngine, FindCodecByName: Don't reassign codecs (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/media/base/rtpdataengine.cc
diff --git a/webrtc/media/base/rtpdataengine.cc b/webrtc/media/base/rtpdataengine.cc
index e21aa00154ecee7edb610ed6e564461937acf2c8..a0c2cfc96eb19721807365f5c2ed5c758e20b24d 100644
--- a/webrtc/media/base/rtpdataengine.cc
+++ b/webrtc/media/base/rtpdataengine.cc
@@ -14,6 +14,7 @@
#include "webrtc/base/helpers.h"
#include "webrtc/base/logging.h"
#include "webrtc/base/ratelimiter.h"
+#include "webrtc/base/stringutils.h"
#include "webrtc/media/base/codec.h"
#include "webrtc/media/base/mediaconstants.h"
#include "webrtc/media/base/rtputils.h"
@@ -46,16 +47,13 @@ DataMediaChannel* RtpDataEngine::CreateChannel(
return new RtpDataMediaChannel();
}
-bool FindCodecByName(const std::vector<DataCodec>& codecs,
- const std::string& name, DataCodec* codec_out) {
- std::vector<DataCodec>::const_iterator iter;
- for (iter = codecs.begin(); iter != codecs.end(); ++iter) {
- if (iter->name == name) {
- *codec_out = *iter;
- return true;
- }
+static const DataCodec* FindCodecByName(const std::vector<DataCodec>& codecs,
+ const std::string& name) {
+ for (const DataCodec& codec : codecs) {
+ if (_stricmp(name.c_str(), codec.name.c_str()) == 0)
+ return &codec;
}
- return false;
+ return nullptr;
}
RtpDataMediaChannel::RtpDataMediaChannel() {
@@ -292,8 +290,9 @@ bool RtpDataMediaChannel::SendData(
return false;
}
- DataCodec found_codec;
- if (!FindCodecByName(send_codecs_, kGoogleRtpDataCodecName, &found_codec)) {
+ const DataCodec* found_codec =
+ FindCodecByName(send_codecs_, kGoogleRtpDataCodecName);
+ if (!found_codec) {
LOG(LS_WARNING) << "Not sending data because codec is unknown: "
<< kGoogleRtpDataCodecName;
return false;
@@ -316,7 +315,7 @@ bool RtpDataMediaChannel::SendData(
}
RtpHeader header;
- header.payload_type = found_codec.id;
+ header.payload_type = found_codec->id;
header.ssrc = params.ssrc;
rtp_clock_by_send_ssrc_[header.ssrc]->Tick(
now, &header.seq_num, &header.timestamp);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698