On Fri, Mar 23, 2018 at 1:34 PM, Andriy Tylychko
<
andriy....@gmail.com> wrote:
> I tried to implement a custom `VideoTrackSourceInterface` but seems it's not
> enough, as I didn't have any notification when it should start capturing and
> a couple of other incompletenesses.
You could start capturing when you get the first AddOrUpdateSink
(before that, you have nowhere to send captured frames).
> rtc::scoped_refptr<webrtc::VideoTrackInterface> video_track(
> peer_connection_factory_->CreateVideoTrack(
> kVideoLabel,
> peer_connection_factory_->CreateVideoSource(std::move(custom_capturer_))));
>
> Please let me know if I'm doing something wrong or if there's a
> simpler/better solution.
As I said, cricket::VideoCapturer is deprecated. The above
CreateVideoSource method will be deleted at some point.
> First of all, when capturer is started encoder is not ready yet, so capturer
> already sent several frames (including SPS/PPS and key-frame) that are
> dropped all except that last one by `VideoStreamEncoder::EncodeTask::Run()`.
> While this state can be recovered by requesting a new key-frame with
> SPS/PPS, but still is unfortunate and I'd rather avoid this. I kind of
> worked this around but it's an ugly hack. Please let me know if there's a
> clear indication that the pipeline is ready so capturing can be started w/o
> dropping frames.
As far as I'm aware, the pipeline should be ready by the time the
video source gets the first AddOrUpdateSink.
> Much more subtle issue I'm faced with is dropping frames in the middle of
> streaming by the same `VideoStreamEncoder::EncodeTask::Run()`. The capturer
> produces pre-encoded frames with 30FPS. The encoder is a fake one that just
> do packing and so should be extremely fast. That's why I don't understand
> while it happens that the capturer manages to produce another frame when the
> prev one haven't been consumed yet by the encoder.
I guess you could signal "encoder ready" to the source behind the
scenes, but that's not very pretty.
> Is there any way to disable frame dropping? if there're multiple places
> where frames can be dropped and no single solution for all of them, is there
> a way to disable frame dropping by `VideoStreamEncoder::EncodeTask::Run()`?
It might make sense to make the limit on number of queued frames configurable.
And there might be other places on the pipeline that can drop frames.
> Also I don't see a possibility to provide a
> customize `VideoStreamEncoder` implementation (at least a simple one).
No, it's not easily replaceable.
Your usecase is a bit unusual, but I'd expect there are quite a few
applications that want to do this. Please file bugs for any serious
obstacles you encounter.