From 3f2803d31d33a2bdd7a056ca9f95e657621a0811 Mon Sep 17 00:00:00 2001 From: lizarge Date: Tue, 29 Dec 2015 15:57:49 +0200 Subject: [PATCH 1/2] - add frame update functional --- api/iOS/VCSimpleSession.mm | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/api/iOS/VCSimpleSession.mm b/api/iOS/VCSimpleSession.mm index ef83e2bc..95536daf 100644 --- a/api/iOS/VCSimpleSession.mm +++ b/api/iOS/VCSimpleSession.mm @@ -853,6 +853,7 @@ - (void) addEncodersAndPacketizers } +/* - (void) addPixelBufferSource: (UIImage*) image withRect:(CGRect)rect { CGImageRef ref = [image CGImage]; @@ -890,7 +891,54 @@ - (void) addPixelBufferSource: (UIImage*) image free(rawData); +}*/ + +- (void) addPixelBufferSource: (UIImage*) image +withRect:(CGRect)rect { +CGImageRef ref = [image CGImage]; + +std::shared_ptr temp_pixelBufferSource = m_pixelBufferSource; + + +m_pixelBufferSource = std::make_shared(CGImageGetWidth(ref), +CGImageGetHeight(ref), +'BGRA'); +NSUInteger width = CGImageGetWidth(ref); +NSUInteger height = CGImageGetHeight(ref); +CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); +unsigned char *rawData = (unsigned char*) calloc(height * width * 4, sizeof(unsigned char)); +NSUInteger bytesPerPixel = 4; +NSUInteger bytesPerRow = bytesPerPixel * width; +NSUInteger bitsPerComponent = 8; +CGContextRef context = CGBitmapContextCreate(rawData, width, height, +bitsPerComponent, bytesPerRow, colorSpace, +kCGImageAlphaPremultipliedFirst | kCGBitmapByteOrder32Little); +CGColorSpaceRelease(colorSpace); + +CGContextDrawImage(context, CGRectMake(0, 0, width, height), ref); +CGContextRelease(context); + +m_pbAspect = std::make_shared(rect.size.width,rect.size.height,videocore::AspectTransform::kAspectFit); + +m_pbPosition = std::make_shared(rect.origin.x, rect.origin.y, +rect.size.width, rect.size.height, +self.videoSize.width, self.videoSize.height +); +m_pixelBufferSource->setOutput(m_pbAspect); +m_pbAspect->setOutput(m_pbPosition); +m_pbPosition->setOutput(m_videoMixer); +m_videoMixer->registerSource(m_pixelBufferSource); +m_pixelBufferSource->pushPixelBuffer(rawData, width * height * 4); + +free(rawData); + + +if(temp_pixelBufferSource){ +m_videoMixer->unregisterSource(temp_pixelBufferSource); } + +} + - (NSString *) applicationDocumentsDirectory { NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); From be9a06fd87bb292d4d05c62e82d3d21f59dd0725 Mon Sep 17 00:00:00 2001 From: User Date: Mon, 18 Apr 2016 12:47:13 +0300 Subject: [PATCH 2/2] Fixed bug in VCSimpleSession --- api/iOS/VCSimpleSession.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/api/iOS/VCSimpleSession.mm b/api/iOS/VCSimpleSession.mm index 95536daf..5ec32b55 100644 --- a/api/iOS/VCSimpleSession.mm +++ b/api/iOS/VCSimpleSession.mm @@ -818,9 +818,10 @@ - (void) addEncodersAndPacketizers self.fps, self.bitrate); } - m_audioMixer->setOutput(m_aacEncoder); - m_videoSplit->setOutput(m_h264Encoder); - + if (m_aacEncoder != nullptr && m_h264Encoder != nullptr) { + m_audioMixer->setOutput(m_aacEncoder); + m_videoSplit->setOutput(m_h264Encoder); + } } { m_aacSplit = std::make_shared();