mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2026-06-18 14:41:14 +00:00
Refactor decoder interface to pass decode unit into VideoDecoderRenderer
This commit is contained in:
@@ -166,8 +166,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit)
|
|||||||
ret = [renderer submitDecodeBuffer:(unsigned char*)entry->data
|
ret = [renderer submitDecodeBuffer:(unsigned char*)entry->data
|
||||||
length:entry->length
|
length:entry->length
|
||||||
bufferType:entry->bufferType
|
bufferType:entry->bufferType
|
||||||
frameType:decodeUnit->frameType
|
decodeUnit:decodeUnit];
|
||||||
pts:decodeUnit->presentationTimeMs];
|
|
||||||
if (ret != DR_OK) {
|
if (ret != DR_OK) {
|
||||||
free(data);
|
free(data);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -185,8 +184,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit)
|
|||||||
return [renderer submitDecodeBuffer:data
|
return [renderer submitDecodeBuffer:data
|
||||||
length:offset
|
length:offset
|
||||||
bufferType:BUFFER_TYPE_PICDATA
|
bufferType:BUFFER_TYPE_PICDATA
|
||||||
frameType:decodeUnit->frameType
|
decodeUnit:decodeUnit];
|
||||||
pts:decodeUnit->presentationTimeMs];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int flags)
|
int ArInit(int audioConfiguration, POPUS_MULTISTREAM_CONFIGURATION opusConfig, void* context, int flags)
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#import "ConnectionCallbacks.h"
|
#import "ConnectionCallbacks.h"
|
||||||
|
|
||||||
|
#include "Limelight.h"
|
||||||
|
|
||||||
@interface VideoDecoderRenderer : NSObject
|
@interface VideoDecoderRenderer : NSObject
|
||||||
|
|
||||||
- (id)initWithView:(UIView*)view callbacks:(id<ConnectionCallbacks>)callbacks streamAspectRatio:(float)aspectRatio useFramePacing:(BOOL)useFramePacing;
|
- (id)initWithView:(UIView*)view callbacks:(id<ConnectionCallbacks>)callbacks streamAspectRatio:(float)aspectRatio useFramePacing:(BOOL)useFramePacing;
|
||||||
@@ -19,6 +21,6 @@
|
|||||||
- (void)stop;
|
- (void)stop;
|
||||||
- (void)setHdrMode:(BOOL)enabled;
|
- (void)setHdrMode:(BOOL)enabled;
|
||||||
|
|
||||||
- (int)submitDecodeBuffer:(unsigned char *)data length:(int)length bufferType:(int)bufferType frameType:(int)frameType pts:(unsigned int)pts;
|
- (int)submitDecodeBuffer:(unsigned char *)data length:(int)length bufferType:(int)bufferType decodeUnit:(PDECODE_UNIT)du;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -9,8 +9,6 @@
|
|||||||
#import "VideoDecoderRenderer.h"
|
#import "VideoDecoderRenderer.h"
|
||||||
#import "StreamView.h"
|
#import "StreamView.h"
|
||||||
|
|
||||||
#include "Limelight.h"
|
|
||||||
|
|
||||||
@implementation VideoDecoderRenderer {
|
@implementation VideoDecoderRenderer {
|
||||||
StreamView* _view;
|
StreamView* _view;
|
||||||
id<ConnectionCallbacks> _callbacks;
|
id<ConnectionCallbacks> _callbacks;
|
||||||
@@ -177,12 +175,12 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
}
|
}
|
||||||
|
|
||||||
// This function must free data for bufferType == BUFFER_TYPE_PICDATA
|
// This function must free data for bufferType == BUFFER_TYPE_PICDATA
|
||||||
- (int)submitDecodeBuffer:(unsigned char *)data length:(int)length bufferType:(int)bufferType frameType:(int)frameType pts:(unsigned int)pts
|
- (int)submitDecodeBuffer:(unsigned char *)data length:(int)length bufferType:(int)bufferType decodeUnit:(PDECODE_UNIT)du
|
||||||
{
|
{
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
|
|
||||||
// Construct a new format description object each time we receive an IDR frame
|
// Construct a new format description object each time we receive an IDR frame
|
||||||
if (frameType == FRAME_TYPE_IDR) {
|
if (du->frameType == FRAME_TYPE_IDR) {
|
||||||
if (bufferType != BUFFER_TYPE_PICDATA) {
|
if (bufferType != BUFFER_TYPE_PICDATA) {
|
||||||
if (bufferType == BUFFER_TYPE_VPS || bufferType == BUFFER_TYPE_SPS || bufferType == BUFFER_TYPE_PPS) {
|
if (bufferType == BUFFER_TYPE_VPS || bufferType == BUFFER_TYPE_SPS || bufferType == BUFFER_TYPE_PPS) {
|
||||||
// Add new parameter set into the parameter set array
|
// Add new parameter set into the parameter set array
|
||||||
@@ -198,7 +196,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
// No frame data to submit for these NALUs
|
// No frame data to submit for these NALUs
|
||||||
return DR_OK;
|
return DR_OK;
|
||||||
}
|
}
|
||||||
else if (frameType == FRAME_TYPE_IDR && formatDesc == NULL) {
|
else if (formatDesc == NULL) {
|
||||||
// Create the new format description when we get the first picture data buffer of an IDR frame.
|
// Create the new format description when we get the first picture data buffer of an IDR frame.
|
||||||
// This is the only way we know that there is no more CSD for this frame.
|
// This is the only way we know that there is no more CSD for this frame.
|
||||||
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
if (videoFormat & VIDEO_FORMAT_MASK_H264) {
|
||||||
@@ -355,7 +353,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
|
|
||||||
CMSampleBufferRef sampleBuffer;
|
CMSampleBufferRef sampleBuffer;
|
||||||
|
|
||||||
CMSampleTimingInfo sampleTiming = {kCMTimeInvalid, CMTimeMake(pts, 1000), kCMTimeInvalid};
|
CMSampleTimingInfo sampleTiming = {kCMTimeInvalid, CMTimeMake(du->presentationTimeMs, 1000), kCMTimeInvalid};
|
||||||
|
|
||||||
status = CMSampleBufferCreateReady(kCFAllocatorDefault,
|
status = CMSampleBufferCreateReady(kCFAllocatorDefault,
|
||||||
frameBlockBuffer,
|
frameBlockBuffer,
|
||||||
@@ -372,7 +370,7 @@ int DrSubmitDecodeUnit(PDECODE_UNIT decodeUnit);
|
|||||||
// Enqueue the next frame
|
// Enqueue the next frame
|
||||||
[self->displayLayer enqueueSampleBuffer:sampleBuffer];
|
[self->displayLayer enqueueSampleBuffer:sampleBuffer];
|
||||||
|
|
||||||
if (frameType == FRAME_TYPE_IDR) {
|
if (du->frameType == FRAME_TYPE_IDR) {
|
||||||
// Ensure the layer is visible now
|
// Ensure the layer is visible now
|
||||||
self->displayLayer.hidden = NO;
|
self->displayLayer.hidden = NO;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user