|
|
Created:
4 years, 1 month ago by magjed_webrtc Modified:
4 years, 1 month ago Reviewers:
kthelgason, hta-webrtc CC:
webrtc-reviews_webrtc.org, tterriberry_mozilla.com, the sun Target Ref:
refs/pending/heads/master Project:
webrtc Visibility:
Public. |
DescriptionReplace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec
This CL introduces two new functions to the WebRtcVideoEncoderFactory
interface based on cricket::VideoFormat instead of
WebRtcVideoEncoderFactory::VideoCodec. The functions are:
WebRtcVideoEncoderFactory::CreateVideoEncoder() and
WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth
transition to the new interface, the old functions are kept, and default
implementations are provided for both the old and new functions so that
external clients can switch from the old to the new functions in peace.
The default implementations will just convert between
cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all
external clients have updated their code, the plan is to remove the old
functions and all default implementations to make
WebRtcVideoEncoderFactory a pure interface again.
BUG=webrtc:6402, webrtc:6337
Committed: https://crrev.com/1e45cc6ee0b368f7cb8b90acc7fe4c1699bb4288
Cr-Commit-Position: refs/heads/master@{#14826}
Patch Set 1 #
Total comments: 6
Patch Set 2 : Extract IsCodecSupportedFunction #Patch Set 3 : Compare only codec names, not VideoCodec::Matches #
Created: 4 years, 1 month ago
Messages
Total messages: 33 (24 generated)
Patchset #1 (id:1) has been deleted
Description was changed from ========== WIP: Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec BUG=webrtc:6402 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec BUG=webrtc:6402 ==========
The CQ bit was checked by magjed@webrtc.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was unchecked by magjed@webrtc.org
The CQ bit was checked by magjed@webrtc.org to run a CQ dry run
Patchset #1 (id:20001) has been deleted
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
The CQ bit was checked by magjed@webrtc.org to run a CQ dry run
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
Patchset #1 (id:40001) has been deleted
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec BUG=webrtc:6402 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc distinguishs different H264 profiles. BUG=webrtc:6402 ==========
magjed@webrtc.org changed reviewers: + hta@webrtc.org, kthelgason@webrtc.org
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc distinguishs different H264 profiles. BUG=webrtc:6402 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc distinguishs different H264 profiles. BUG=webrtc:6402 ==========
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc distinguishs different H264 profiles. BUG=webrtc:6402 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc can distinguishs between different H264 profiles. BUG=webrtc:6402 ==========
Please take a look.
The CQ bit was unchecked by commit-bot@chromium.org
Dry run: This issue passed the CQ dry run.
some small suggestions, otherwise lgtm https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... File webrtc/media/engine/webrtcvideoengine2.cc (right): https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... webrtc/media/engine/webrtcvideoengine2.cc:658: } This code exists in a few places. We could use std::any_of here to avoid manually writing the loop, and to make the intent more clear. https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... webrtc/media/engine/webrtcvideoengine2.cc:730: } The inner loop here is identical to a previous one in this class. Perhaps we can extract that out into a function, perhaps "bool IsCodecSupported(VideoCodec codec)" and reuse that here. Then this whole thing could be a single std::copy_if call.
Patchset #2 (id:80001) has been deleted
https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... File webrtc/media/engine/webrtcvideoengine2.cc (right): https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... webrtc/media/engine/webrtcvideoengine2.cc:658: } On 2016/10/28 08:26:54, kthelgason wrote: > This code exists in a few places. We could use std::any_of here to avoid > manually writing the loop, and to make the intent more clear. Thanks! Much better to extract it to a function. I went with std::any_of, but it might not be more clear than a regular for-loop. It's this: return std::any_of(supported_codecs.begin(), supported_codecs.end(), [&codec](const VideoCodec& supported_codec) -> bool { return supported_codec.Matches(codec); }); vs this: for (const VideoCodec& supported_codec : supported_codecs) { if (supported_codec.Matches(codec)) return true; } return false; https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... webrtc/media/engine/webrtcvideoengine2.cc:730: } On 2016/10/28 08:26:54, kthelgason wrote: > The inner loop here is identical to a previous one in this class. Perhaps we can > extract that out into a function, perhaps "bool IsCodecSupported(VideoCodec > codec)" and reuse that here. Then this whole thing could be a single > std::copy_if call. Done, the inner loop is now extracted out into a IsCodecSupported helper function. I didn't go with std::copy_if, because I think it adds more noise than clarity. It's this: std::copy_if( mapped_codecs.begin(), mapped_codecs.end(), std::back_inserter(filtered_codecs), [&supported_codecs](const VideoCodecSettings& mapped_codec) -> bool { return IsCodecSupported(supported_codecs, mapped_codec.codec); }); vs for (const VideoCodecSettings& mapped_codec : mapped_codecs) { if (IsCodecSupported(supported_codecs, mapped_codec.codec)) filtered_codecs.push_back(mapped_codec); }
lgtm I assume that all tests pass and that it works with Chrome... we should eventually delete all code that has payload type within the codec, because we should be capable of supporting scenarios with more than one payload type pointing to the same codec (it's a map, not an equality) - but that's not part of this CL.
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc can distinguishs between different H264 profiles. BUG=webrtc:6402 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc can distinguishs between different H264 profiles. BUG=webrtc:6402,webrtc:6337 ==========
https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... File webrtc/media/engine/webrtcvideoengine2.cc (right): https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... webrtc/media/engine/webrtcvideoengine2.cc:730: } On 2016/10/28 10:27:31, magjed_webrtc wrote: > On 2016/10/28 08:26:54, kthelgason wrote: > > The inner loop here is identical to a previous one in this class. Perhaps we > can > > extract that out into a function, perhaps "bool IsCodecSupported(VideoCodec > > codec)" and reuse that here. Then this whole thing could be a single > > std::copy_if call. > > Done, the inner loop is now extracted out into a IsCodecSupported helper > function. I didn't go with std::copy_if, because I think it adds more noise than > clarity. I agree with your assessment that this adds more noise than clarity. I had imagined something like: std::copy_if(mapped_codecs.begin(), mapped_codecs.end(), std::back_inserter(filtered_codecs), &IsCodecSupported) but this is not javascript, and that obviously does not work :)
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. Another change in this CL is that webrtcvideoengine2.cc is updated to compare cricket::VideoCodecs using 'bool VideoCodec::Matches(const VideoCodec& codec) const' instead of just comparing codec names. The purpose is to prepare for H264 profile matching in VideoCodec::Matches so that webrtcvideoengine2.cc can distinguishs between different H264 profiles. BUG=webrtc:6402,webrtc:6337 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. BUG=webrtc:6402,webrtc:6337 ==========
I had to revert comparing codecs with VideoCodec::Matches and compare using codec names for now. The problem is that VideoCodec::Matches is looking at the payload_id which complicates things. I need to fix this in a future CL so that different H264 profiles can be added. https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... File webrtc/media/engine/webrtcvideoengine2.cc (right): https://codereview.webrtc.org/2449993003/diff/60001/webrtc/media/engine/webrt... webrtc/media/engine/webrtcvideoengine2.cc:730: } On 2016/10/28 13:19:45, kthelgason wrote: > On 2016/10/28 10:27:31, magjed_webrtc wrote: > > On 2016/10/28 08:26:54, kthelgason wrote: > > > The inner loop here is identical to a previous one in this class. Perhaps we > > can > > > extract that out into a function, perhaps "bool IsCodecSupported(VideoCodec > > > codec)" and reuse that here. Then this whole thing could be a single > > > std::copy_if call. > > > > Done, the inner loop is now extracted out into a IsCodecSupported helper > > function. I didn't go with std::copy_if, because I think it adds more noise > than > > clarity. > > I agree with your assessment that this adds more noise than clarity. I had > imagined something like: > std::copy_if(mapped_codecs.begin(), mapped_codecs.end(), > std::back_inserter(filtered_codecs), &IsCodecSupported) > > but this is not javascript, and that obviously does not work :) > > Yeah, it's close to working with: std::copy_if(mapped_codecs.begin(), mapped_codecs.end(), std::back_inserter(filtered_codecs), std::bind(&IsCodecSupported, supported_codecs)); Not quite though, because: 1. std::bind is not yet an allowed C++11 feature in WebRTC. 2. mapped_codec is of type VideoCodecSettings and not VideoCodec, so I need to do mapped_codec.codec which essentially requires a lambda in C++. Haskell has much nicer and cleaner glue functions :)
The CQ bit was checked by magjed@webrtc.org
The patchset sent to the CQ was uploaded after l-g-t-m from kthelgason@webrtc.org, hta@webrtc.org Link to the patchset: https://codereview.webrtc.org/2449993003/#ps120001 (title: "Compare only codec names, not VideoCodec::Matches")
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/...
Message was sent while issue was closed.
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. BUG=webrtc:6402,webrtc:6337 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. BUG=webrtc:6402,webrtc:6337 ==========
Message was sent while issue was closed.
Committed patchset #3 (id:120001)
Message was sent while issue was closed.
Description was changed from ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. BUG=webrtc:6402,webrtc:6337 ========== to ========== Replace WebRtcVideoEncoderFactory::VideoCodec with cricket::VideoCodec This CL introduces two new functions to the WebRtcVideoEncoderFactory interface based on cricket::VideoFormat instead of WebRtcVideoEncoderFactory::VideoCodec. The functions are: WebRtcVideoEncoderFactory::CreateVideoEncoder() and WebRtcVideoEncoderFactory::supported_codecs(). In order to make a smooth transition to the new interface, the old functions are kept, and default implementations are provided for both the old and new functions so that external clients can switch from the old to the new functions in peace. The default implementations will just convert between cricket::VideoFormat and WebRtcVideoEncoderFactory::VideoCodec. Once all external clients have updated their code, the plan is to remove the old functions and all default implementations to make WebRtcVideoEncoderFactory a pure interface again. BUG=webrtc:6402,webrtc:6337 Committed: https://crrev.com/1e45cc6ee0b368f7cb8b90acc7fe4c1699bb4288 Cr-Commit-Position: refs/heads/master@{#14826} ==========
Message was sent while issue was closed.
Patchset 3 (id:??) landed as https://crrev.com/1e45cc6ee0b368f7cb8b90acc7fe4c1699bb4288 Cr-Commit-Position: refs/heads/master@{#14826} |