Change GetStreamBySsrc to not copy StreamParams.
This is something I stumbled upon while looking at string copying we do (in spades) and did a simple change to not be constantly copying things around needlessly. There's a lot more that can be done in these files of course so this is sort of a reminder for future code edits that it's possible to design interfaces/function in a way that's more performance aware and avoid forcing creation of copies, while still being very simple. Also, we can use lambdas now :) BUG= R=perkj@webrtc.org, pthatcher@webrtc.org Review URL: https://webrtc-codereview.appspot.com/41589004 git-svn-id: http://webrtc.googlecode.com/svn/trunk@8131 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@@ -174,8 +174,7 @@ bool RtpDataMediaChannel::AddSendStream(const StreamParams& stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamParams found_stream;
|
||||
if (GetStreamBySsrc(send_streams_, stream.first_ssrc(), &found_stream)) {
|
||||
if (GetStreamBySsrc(send_streams_, stream.first_ssrc())) {
|
||||
LOG(LS_WARNING) << "Not adding data send stream '" << stream.id
|
||||
<< "' with ssrc=" << stream.first_ssrc()
|
||||
<< " because stream already exists.";
|
||||
@@ -195,8 +194,7 @@ bool RtpDataMediaChannel::AddSendStream(const StreamParams& stream) {
|
||||
}
|
||||
|
||||
bool RtpDataMediaChannel::RemoveSendStream(uint32 ssrc) {
|
||||
StreamParams found_stream;
|
||||
if (!GetStreamBySsrc(send_streams_, ssrc, &found_stream)) {
|
||||
if (!GetStreamBySsrc(send_streams_, ssrc)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -211,8 +209,7 @@ bool RtpDataMediaChannel::AddRecvStream(const StreamParams& stream) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamParams found_stream;
|
||||
if (GetStreamBySsrc(recv_streams_, stream.first_ssrc(), &found_stream)) {
|
||||
if (GetStreamBySsrc(recv_streams_, stream.first_ssrc())) {
|
||||
LOG(LS_WARNING) << "Not adding data recv stream '" << stream.id
|
||||
<< "' with ssrc=" << stream.first_ssrc()
|
||||
<< " because stream already exists.";
|
||||
@@ -269,13 +266,13 @@ void RtpDataMediaChannel::OnPacketReceived(
|
||||
return;
|
||||
}
|
||||
|
||||
StreamParams found_stream;
|
||||
if (!GetStreamBySsrc(recv_streams_, header.ssrc, &found_stream)) {
|
||||
if (!GetStreamBySsrc(recv_streams_, header.ssrc)) {
|
||||
LOG(LS_WARNING) << "Received packet for unknown ssrc: " << header.ssrc;
|
||||
return;
|
||||
}
|
||||
|
||||
// Uncomment this for easy debugging.
|
||||
// const auto* found_stream = GetStreamBySsrc(recv_streams_, header.ssrc);
|
||||
// LOG(LS_INFO) << "Received packet"
|
||||
// << " groupid=" << found_stream.groupid
|
||||
// << ", ssrc=" << header.ssrc
|
||||
@@ -318,8 +315,9 @@ bool RtpDataMediaChannel::SendData(
|
||||
return false;
|
||||
}
|
||||
|
||||
StreamParams found_stream;
|
||||
if (!GetStreamBySsrc(send_streams_, params.ssrc, &found_stream)) {
|
||||
const StreamParams* found_stream =
|
||||
GetStreamBySsrc(send_streams_, params.ssrc);
|
||||
if (!found_stream) {
|
||||
LOG(LS_WARNING) << "Not sending data because ssrc is unknown: "
|
||||
<< params.ssrc;
|
||||
return false;
|
||||
@@ -363,7 +361,7 @@ bool RtpDataMediaChannel::SendData(
|
||||
packet.AppendData(payload.data(), payload.length());
|
||||
|
||||
LOG(LS_VERBOSE) << "Sent RTP data packet: "
|
||||
<< " stream=" << found_stream.id
|
||||
<< " stream=" << found_stream->id
|
||||
<< " ssrc=" << header.ssrc
|
||||
<< ", seqnum=" << header.seq_num
|
||||
<< ", timestamp=" << header.timestamp
|
||||
|
||||
Reference in New Issue
Block a user