Read the frame data out of the CMSampleBuffer
Still not sending it anywhere, but think I'm reading it correctly.
This commit is contained in:
parent
047b5114f1
commit
b51abc5a63
5 changed files with 69 additions and 10 deletions
|
@ -3,6 +3,7 @@ mod compression_session;
|
|||
|
||||
use crate::{bindings::SCStreamOutputType, compression_session::CompressionSession};
|
||||
use block::ConcreteBlock;
|
||||
use byteorder::{BigEndian, ReadBytesExt};
|
||||
use bytes::BytesMut;
|
||||
use cocoa::{
|
||||
base::{id, nil, YES},
|
||||
|
@ -128,6 +129,25 @@ impl ScreenCaptureView {
|
|||
let nal_unit = compression_buffer.split();
|
||||
}
|
||||
}
|
||||
|
||||
let data = sample_buffer.data();
|
||||
let mut data = data.bytes();
|
||||
|
||||
const AVCC_HEADER_LENGTH: usize = 4;
|
||||
while data.len() - AVCC_HEADER_LENGTH > 0 {
|
||||
let nal_unit_len = match data.read_u32::<BigEndian>() {
|
||||
Ok(len) => len as usize,
|
||||
Err(error) => {
|
||||
log::error!("error decoding nal unit length: {}", error);
|
||||
return;
|
||||
}
|
||||
};
|
||||
compression_buffer.extend_from_slice(&START_CODE);
|
||||
compression_buffer.extend_from_slice(&data[..nal_unit_len as usize]);
|
||||
data = &data[nal_unit_len..];
|
||||
|
||||
let nal_unit = compression_buffer.split();
|
||||
}
|
||||
},
|
||||
)
|
||||
.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue