init
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
Some checks failed
Docker. / Ubuntu (push) Has been cancelled
User-agent updater. / User-agent (push) Failing after 15s
Lock Threads / lock (push) Failing after 10s
Waiting for answer. / waiting-for-answer (push) Failing after 22s
Needs user action. / needs-user-action (push) Failing after 8s
Can't reproduce. / cant-reproduce (push) Failing after 8s
Close stale issues and PRs / stale (push) Has been cancelled
This commit is contained in:
62
Telegram/SourceFiles/media/audio/media_child_ffmpeg_loader.h
Normal file
62
Telegram/SourceFiles/media/audio/media_child_ffmpeg_loader.h
Normal file
@@ -0,0 +1,62 @@
|
||||
/*
|
||||
This file is part of Telegram Desktop,
|
||||
the official desktop application for the Telegram messaging service.
|
||||
|
||||
For license and copyright information please follow this link:
|
||||
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include "media/audio/media_audio_ffmpeg_loader.h"
|
||||
#include "media/streaming/media_streaming_utility.h"
|
||||
|
||||
namespace Media {
|
||||
|
||||
struct ExternalSoundData {
|
||||
FFmpeg::CodecPointer codec;
|
||||
FFmpeg::FramePointer frame;
|
||||
crl::time duration = 0;
|
||||
float64 speed = 1.; // 0.5 <= speed <= 2.
|
||||
};
|
||||
|
||||
struct ExternalSoundPart {
|
||||
AudioMsgId audio;
|
||||
gsl::span<FFmpeg::Packet> packets;
|
||||
};
|
||||
|
||||
class ChildFFMpegLoader : public AbstractAudioFFMpegLoader {
|
||||
public:
|
||||
ChildFFMpegLoader(std::unique_ptr<ExternalSoundData> &&data);
|
||||
|
||||
bool open(crl::time positionMs, float64 speed = 1.) override;
|
||||
|
||||
bool check(const Core::FileLocation &file, const QByteArray &data) override {
|
||||
return true;
|
||||
}
|
||||
|
||||
ReadResult readMore() override;
|
||||
void enqueuePackets(std::deque<FFmpeg::Packet> &&packets) override;
|
||||
void setForceToBuffer(bool force) override;
|
||||
bool forceToBuffer() const override;
|
||||
|
||||
bool eofReached() const {
|
||||
return _eofReached;
|
||||
}
|
||||
|
||||
~ChildFFMpegLoader();
|
||||
|
||||
private:
|
||||
// Streaming player reads first frame by itself and provides it together
|
||||
// with the codec context. So we first read data from this frame and
|
||||
// only after that we try to read next packets.
|
||||
ReadResult readFromInitialFrame();
|
||||
|
||||
std::unique_ptr<ExternalSoundData> _parentData;
|
||||
std::deque<FFmpeg::Packet> _queue;
|
||||
bool _forceToBuffer = false;
|
||||
bool _eofReached = false;
|
||||
bool _readTillEnd = false;
|
||||
|
||||
};
|
||||
|
||||
} // namespace Media
|
||||
Reference in New Issue
Block a user