mirror of
https://github.com/moonlight-stream/moonlight-ios.git
synced 2025-07-22 12:13:35 +00:00
Fix missing video issue
This commit is contained in:
parent
ef98976ebf
commit
1b98870b41
@ -10,10 +10,9 @@
|
|||||||
|
|
||||||
@implementation VideoDecoderRenderer {
|
@implementation VideoDecoderRenderer {
|
||||||
AVSampleBufferDisplayLayer* displayLayer;
|
AVSampleBufferDisplayLayer* displayLayer;
|
||||||
Boolean waitingForSps, waitingForPpsA, waitingForPpsB;
|
Boolean waitingForSps, waitingForPps;
|
||||||
|
|
||||||
NSData *spsData, *ppsDataA, *ppsDataB;
|
NSData *spsData, *ppsData;
|
||||||
unsigned char ppsDataAFirstByte;
|
|
||||||
CMVideoFormatDescriptionRef formatDesc;
|
CMVideoFormatDescriptionRef formatDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,8 +29,7 @@
|
|||||||
|
|
||||||
// We need some parameter sets before we can properly start decoding frames
|
// We need some parameter sets before we can properly start decoding frames
|
||||||
waitingForSps = true;
|
waitingForSps = true;
|
||||||
waitingForPpsA = true;
|
waitingForPps = true;
|
||||||
waitingForPpsB = true;
|
|
||||||
|
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
@ -114,34 +112,27 @@
|
|||||||
unsigned char nalType = data[FRAME_START_PREFIX_SIZE] & 0x1F;
|
unsigned char nalType = data[FRAME_START_PREFIX_SIZE] & 0x1F;
|
||||||
OSStatus status;
|
OSStatus status;
|
||||||
|
|
||||||
if (formatDesc == NULL && (nalType == 0x7 || nalType == 0x8)) {
|
if (nalType == 0x7 || nalType == 0x8) {
|
||||||
if (waitingForSps && nalType == 0x7) {
|
if (nalType == 0x7) {
|
||||||
printf("Got SPS\n");
|
printf("Got SPS\n");
|
||||||
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
spsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
waitingForSps = false;
|
waitingForSps = false;
|
||||||
|
|
||||||
|
// We got a new SPS so wait for a new PPS to match it
|
||||||
|
waitingForPps = true;
|
||||||
}
|
}
|
||||||
// Nvidia's stream has 2 PPS NALUs so we'll wait for both of them
|
else if (nalType == 0x8) {
|
||||||
else if ((waitingForPpsA || waitingForPpsB) && nalType == 0x8) {
|
printf("Got PPS\n");
|
||||||
// Read the NALU's PPS index to figure out which PPS this is
|
ppsData = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
||||||
if (waitingForPpsA) {
|
waitingForPps = false;
|
||||||
printf("Got PPS 1\n");
|
|
||||||
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
|
||||||
waitingForPpsA = false;
|
|
||||||
ppsDataAFirstByte = data[FRAME_START_PREFIX_SIZE + 1];
|
|
||||||
}
|
|
||||||
else if (data[FRAME_START_PREFIX_SIZE + 1] != ppsDataAFirstByte) {
|
|
||||||
printf("Got PPS 2\n");
|
|
||||||
ppsDataA = [NSData dataWithBytes:&data[FRAME_START_PREFIX_SIZE] length:length - FRAME_START_PREFIX_SIZE];
|
|
||||||
waitingForPpsB = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// See if we've got all the parameter sets we need
|
// See if we've got all the parameter sets we need
|
||||||
if (!waitingForSps && !waitingForPpsA && !waitingForPpsB) {
|
if (!waitingForSps && !waitingForPps) {
|
||||||
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsDataA bytes], [ppsDataB bytes] };
|
const uint8_t* const parameterSetPointers[] = { [spsData bytes], [ppsData bytes] };
|
||||||
const size_t parameterSetSizes[] = { [spsData length], [ppsDataA length], [ppsDataB length] };
|
const size_t parameterSetSizes[] = { [spsData length], [ppsData length] };
|
||||||
|
|
||||||
printf("Constructing format description\n");
|
printf("Constructing new format description\n");
|
||||||
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
status = CMVideoFormatDescriptionCreateFromH264ParameterSets(kCFAllocatorDefault,
|
||||||
2, /* count of parameter sets */
|
2, /* count of parameter sets */
|
||||||
parameterSetPointers,
|
parameterSetPointers,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user