Skip to content

Commit

Permalink
fix ios video render
Browse files Browse the repository at this point in the history
  • Loading branch information
boyan01 committed Jun 13, 2021
1 parent a19ad6f commit 1921215
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
27 changes: 17 additions & 10 deletions ios/Classes/DarwinVideoRendererSink.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,14 @@ - (CVPixelBufferRef)copyPixelBuffer {
}

- (void)setPixelBuffer:(CVPixelBufferRef)pixelBuffer {
@synchronized (self) {
if (_pixelBuffer != nil) {
CVPixelBufferRelease(_pixelBuffer);
}
_pixelBuffer = pixelBuffer;
CVPixelBufferRetain(_pixelBuffer);
}

@synchronized (self) {
if (_pixelBuffer != nil) {
CVPixelBufferRelease(_pixelBuffer);
}
_pixelBuffer = pixelBuffer;
CVPixelBufferRetain(_pixelBuffer);
}

}

Expand All @@ -68,9 +68,12 @@ - (void)setPixelBuffer:(CVPixelBufferRef)pixelBuffer {
: texture_id_(texture_id),
texture_(texture),
cv_pixel_buffer_ref_(nullptr){

}

~MacosFlutterTexture() override = default;
~MacosFlutterTexture() override {

}

int64_t GetTextureId() override
{
Expand All @@ -92,11 +95,15 @@ PixelFormat GetSupportFormat() override {
}

void MaybeInitPixelBuffer(int width, int height) override {
NSDictionary* cvBufferProperties = @{
(__bridge NSString*)kCVPixelBufferOpenGLCompatibilityKey : @YES,
(__bridge NSString*)kCVPixelBufferMetalCompatibilityKey : @YES,
};
auto ret = CVPixelBufferCreate(kCFAllocatorDefault,
width,
height,
kCVPixelFormatType_32BGRA,
nullptr,
(__bridge CFDictionaryRef) cvBufferProperties,
&cv_pixel_buffer_ref_);
if (ret != kCVReturnSuccess) {
cv_pixel_buffer_ref_ = nullptr;
Expand Down
4 changes: 4 additions & 0 deletions ios/Classes/LycheePlayerPlugin.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#if TARGET_OS_IPHONE
#import <Flutter/Flutter.h>
#else
#import <FlutterMacOS/FlutterMacOS.h>
#endif

@interface LycheePlayerPlugin : NSObject<FlutterPlugin>
@end

1 comment on commit 1921215

@boyan01
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

close #26

Please sign in to comment.