-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Apple): support set CicadaRenderDelegate
- Loading branch information
Showing
8 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
|
||
#ifndef CicadaRenderCBWrapper_H | ||
#define CicadaRenderCBWrapper_H | ||
|
||
class IAFFrame; | ||
|
||
class CicadaRenderCBWrapper { | ||
public: | ||
static bool OnRenderFrame(void *userData, IAFFrame *frame); | ||
}; | ||
|
||
|
||
#endif //CicadaRenderCBWrapper_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#import "CicadaRenderCBWrapper.h" | ||
#import <base/media/PBAFFrame.h> | ||
#import "CicadaRenderDelegate.h" | ||
|
||
bool CicadaRenderCBWrapper::OnRenderFrame(void *userData, IAFFrame *frame) | ||
{ | ||
id<CicadaRenderDelegate> delegate = (__bridge id<CicadaRenderDelegate>)userData; | ||
if (nullptr == delegate) { | ||
return false; | ||
} | ||
|
||
if (frame->getType() == IAFFrame::FrameTypeVideo) { | ||
switch (frame->getInfo().format) { | ||
case AF_PIX_FMT_APPLE_PIXEL_BUFFER: { | ||
auto *ppBFrame = dynamic_cast<PBAFFrame *>(frame); | ||
CVPixelBufferRef pixelBuffer = ppBFrame->getPixelBuffer(); | ||
if ([delegate respondsToSelector:@selector(onVideoPixelBuffer:pts:)]){ | ||
return [delegate onVideoPixelBuffer:pixelBuffer pts:frame->getInfo().pts]; | ||
} | ||
break; | ||
} | ||
case AF_PIX_FMT_YUV420P: | ||
if ([delegate respondsToSelector:@selector(onVideoPixelBuffer:pts:)]){ | ||
return [delegate onVideoRawBuffer:frame->getData() | ||
lineSize:frame->getLineSize() | ||
pts:frame->getInfo().pts | ||
width:frame->getInfo().video.width | ||
height:frame->getInfo().video.height]; | ||
} | ||
break; | ||
default: | ||
break; | ||
} | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@protocol CicadaRenderDelegate <NSObject> | ||
@optional | ||
|
||
/** | ||
* 视频硬解渲染帧回调 | ||
* @param pixelBuffer 渲染帧 | ||
* @param pts 渲染帧pts | ||
* @return 返回YES则SDK不再显示(暂不支持);返回NO则SDK渲染模块继续渲染 | ||
*/ | ||
- (BOOL)onVideoPixelBuffer:(CVPixelBufferRef)pixelBuffer pts:(int64_t)pts; | ||
|
||
/** | ||
* 视频软解渲染帧回调 | ||
* @param pixelBuffer 渲染帧 | ||
* @param pts 渲染帧pts | ||
* @return 返回YES则SDK不再显示(暂不支持);返回NO则SDK渲染模块继续渲染 | ||
*/ | ||
- (BOOL)onVideoRawBuffer:(uint8_t **)buffer lineSize:(int32_t *)lineSize pts:(int64_t)pts width:(int32_t)width height:(int32_t)height; | ||
|
||
@end |