7#include "pipewireencodedstream.h"
8#include "pipewireencodedstream_p.h"
9#include "pipewireproduce_p.h"
13#include <libavcodec/packet.h>
16class PipeWirePacketPrivate
19 PipeWirePacketPrivate(
bool isKey,
const QByteArray &data)
29PipeWireEncodedStream::Packet::Packet(
bool isKey,
const QByteArray &data)
30 : d(std::make_shared<PipeWirePacketPrivate>(isKey, data))
34QByteArray PipeWireEncodedStream::Packet::data()
const
39bool PipeWireEncodedStream::Packet::isKeyFrame()
const
44PipeWireEncodeProduce::PipeWireEncodeProduce(PipeWireBaseEncodedStream::Encoder encoder,
47 const Fraction &framerate,
48 PipeWireEncodedStream *stream)
49 : PipeWireProduce(encoder, nodeId, fd, framerate)
50 , m_encodedStream(stream)
54void PipeWireEncodeProduce::processPacket(AVPacket *packet)
60 Q_EMIT newPacket(PipeWireEncodedStream::Packet(packet->flags & AV_PKT_FLAG_KEY,
QByteArray(
reinterpret_cast<char *
>(packet->data), packet->size)));
63void PipeWireEncodeProduce::processFrame(
const PipeWireFrame &frame)
65 if (m_size != m_stream->size()) {
66 m_size = m_stream->size();
67 Q_EMIT m_encodedStream->sizeChanged(m_size);
70 PipeWireProduce::processFrame(frame);
71 if (frame.cursor && m_cursor != *frame.cursor) {
72 m_cursor = *frame.cursor;
73 Q_EMIT m_encodedStream->cursorChanged(m_cursor);
77PipeWireEncodedStream::PipeWireEncodedStream(
QObject *parent)
78 : PipeWireBaseEncodedStream(parent)
82PipeWireEncodedStream::~PipeWireEncodedStream() =
default;
84std::unique_ptr<PipeWireProduce> PipeWireEncodedStream::makeProduce()
86 auto produce =
new PipeWireEncodeProduce(encoder(), nodeId(), fd(), maxFramerate(),
this);
87 connect(produce, &PipeWireEncodeProduce::newPacket,
this, &PipeWireEncodedStream::newPacket);
88 connect(
this, &PipeWireEncodedStream::maxFramerateChanged, produce, [
this, produce]() {
89 produce->setMaxFramerate(maxFramerate());
91 return std::unique_ptr<PipeWireProduce>(produce);
94#include "moc_pipewireencodedstream_p.cpp"
96#include "moc_pipewireencodedstream.cpp"
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)