Skip to content

Commit 424816d

Browse files
committed
Address safer C++ static analysis warnings in SourceBufferParserAVFObjC.mm
https://bugs.webkit.org/show_bug.cgi?id=287384 rdar://144528243 Reviewed by Jean-Yves Avenard. * Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations: * Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.h: * Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm: (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:]): (-[WebAVStreamDataParserListener streamDataParser:didParseStreamDataAsAsset:withDiscontinuity:]): (-[WebAVStreamDataParserListener streamDataParser:didFailToParseStreamDataWithError:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideMediaData:forTrackID:mediaType:flags:]): (-[WebAVStreamDataParserListener streamDataParserWillProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVStreamDataParserListener streamDataParser:didProvideContentKeyRequestInitializationData:forTrackID:]): (-[WebAVStreamDataParserWithKeySpecifierListener streamDataParser:didProvideContentKeySpecifier:forTrackID:]): * Source/WebCore/platform/graphics/cocoa/SourceBufferParser.h: Canonical link: https://commits.webkit.org/290258@main
1 parent 849a3f4 commit 424816d

File tree

4 files changed

+20
-21
lines changed

4 files changed

+20
-21
lines changed

Source/WebCore/SaferCPPExpectations/UncountedCallArgsCheckerExpectations

-1
Original file line numberDiff line numberDiff line change
@@ -1113,7 +1113,6 @@ platform/graphics/avfoundation/objc/CDMInstanceFairPlayStreamingAVFObjC.mm
11131113
platform/graphics/avfoundation/objc/CDMSessionAVContentKeySession.mm
11141114
platform/graphics/avfoundation/objc/LocalSampleBufferDisplayLayer.mm
11151115
platform/graphics/avfoundation/objc/MediaSourcePrivateAVFObjC.mm
1116-
platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm
11171116
platform/graphics/avfoundation/objc/SourceBufferPrivateAVFObjC.mm
11181117
platform/graphics/avfoundation/objc/WebAVContentKeyGroup.mm
11191118
platform/graphics/avfoundation/objc/WebCoreAVFResourceLoader.mm

Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.h

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ namespace WebCore {
4747

4848
class SourceBufferParserAVFObjC final
4949
: public SourceBufferParser
50-
, public CanMakeWeakPtr<SourceBufferParserAVFObjC>
5150
, private LoggerHelper {
5251
public:
5352
static MediaPlayerEnums::SupportsType isContentTypeSupported(const ContentType&);

Source/WebCore/platform/graphics/avfoundation/objc/SourceBufferParserAVFObjC.mm

+18-17
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
#import <pal/avfoundation/MediaTimeAVFoundation.h>
5050
#import <pal/spi/cocoa/AVFoundationSPI.h>
5151
#import <wtf/BlockObjCExceptions.h>
52+
#import <wtf/WeakObjCPtr.h>
5253
#import <wtf/cf/TypeCastsCF.h>
5354
#import <wtf/text/MakeString.h>
5455

@@ -65,10 +66,10 @@ @interface AVContentKeySpecifier (WebCorePrivate)
6566
#endif
6667

6768
@interface WebAVStreamDataParserListener : NSObject<AVStreamDataParserOutputHandling> {
68-
WebCore::SourceBufferParserAVFObjC* _parent;
69-
AVStreamDataParser* _parser;
69+
ThreadSafeWeakPtr<WebCore::SourceBufferParserAVFObjC> _parent;
70+
WeakObjCPtr<AVStreamDataParser> _parser;
7071
}
71-
@property (assign) WebCore::SourceBufferParserAVFObjC* parent;
72+
@property (assign) ThreadSafeWeakPtr<WebCore::SourceBufferParserAVFObjC> parent;
7273
- (id)initWithParser:(AVStreamDataParser*)parser parent:(WebCore::SourceBufferParserAVFObjC*)parent;
7374
@end
7475

@@ -102,43 +103,43 @@ - (void)invalidate
102103

103104
- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didParseStreamDataAsAsset:(AVAsset *)asset
104105
{
105-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
106-
_parent->didParseStreamDataAsAsset(asset);
106+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
107+
_parent.get()->didParseStreamDataAsAsset(asset);
107108
}
108109

109110
- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didParseStreamDataAsAsset:(AVAsset *)asset withDiscontinuity:(BOOL)discontinuity
110111
{
111112
UNUSED_PARAM(discontinuity);
112-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
113-
_parent->didParseStreamDataAsAsset(asset);
113+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
114+
_parent.get()->didParseStreamDataAsAsset(asset);
114115
}
115116

116117
- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didFailToParseStreamDataWithError:(NSError *)error
117118
{
118-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
119-
_parent->didFailToParseStreamDataWithError(error);
119+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
120+
_parent.get()->didFailToParseStreamDataWithError(error);
120121
}
121122

122123
- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didProvideMediaData:(CMSampleBufferRef)sample forTrackID:(CMPersistentTrackID)trackID mediaType:(NSString *)nsMediaType flags:(AVStreamDataParserOutputMediaDataFlags)flags
123124
{
124-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
125-
_parent->didProvideMediaDataForTrackID(trackID, sample, nsMediaType, flags);
125+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
126+
_parent.get()->didProvideMediaDataForTrackID(trackID, sample, nsMediaType, flags);
126127
}
127128

128129
ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
129130
- (void)streamDataParserWillProvideContentKeyRequestInitializationData:(AVStreamDataParser *)streamDataParser forTrackID:(CMPersistentTrackID)trackID
130131
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
131132
{
132-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
133-
_parent->willProvideContentKeyRequestInitializationDataForTrackID(trackID);
133+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
134+
_parent.get()->willProvideContentKeyRequestInitializationDataForTrackID(trackID);
134135
}
135136

136137
ALLOW_DEPRECATED_IMPLEMENTATIONS_BEGIN
137138
- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didProvideContentKeyRequestInitializationData:(NSData *)initData forTrackID:(CMPersistentTrackID)trackID
138139
ALLOW_DEPRECATED_IMPLEMENTATIONS_END
139140
{
140-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
141-
_parent->didProvideContentKeyRequestInitializationDataForTrackID(initData, trackID);
141+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
142+
_parent.get()->didProvideContentKeyRequestInitializationDataForTrackID(initData, trackID);
142143
}
143144

144145
@end
@@ -150,9 +151,9 @@ @interface WebAVStreamDataParserWithKeySpecifierListener : WebAVStreamDataParser
150151
@implementation WebAVStreamDataParserWithKeySpecifierListener
151152
- (void)streamDataParser:(AVStreamDataParser *)streamDataParser didProvideContentKeySpecifier:(AVContentKeySpecifier *)keySpecifier forTrackID:(CMPersistentTrackID)trackID
152153
{
153-
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser);
154+
ASSERT_UNUSED(streamDataParser, streamDataParser == _parser.get());
154155
if ([keySpecifier respondsToSelector:@selector(initializationData)])
155-
_parent->didProvideContentKeyRequestSpecifierForTrackID(keySpecifier.initializationData, trackID);
156+
_parent.get()->didProvideContentKeyRequestSpecifierForTrackID(keySpecifier.initializationData, trackID);
156157
}
157158
@end
158159
#endif

Source/WebCore/platform/graphics/cocoa/SourceBufferParser.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <variant>
3535
#include <wtf/Expected.h>
3636
#include <wtf/RefCounted.h>
37-
#include <wtf/ThreadSafeRefCounted.h>
37+
#include <wtf/ThreadSafeWeakPtr.h>
3838

3939
namespace WTF {
4040
class Logger;
@@ -47,7 +47,7 @@ class MediaSampleAVFObjC;
4747
class SharedBuffer;
4848
struct TrackInfo;
4949

50-
class WEBCORE_EXPORT SourceBufferParser : public ThreadSafeRefCounted<SourceBufferParser, WTF::DestructionThread::Main> {
50+
class WEBCORE_EXPORT SourceBufferParser : public ThreadSafeRefCountedAndCanMakeThreadSafeWeakPtr<SourceBufferParser, WTF::DestructionThread::Main> {
5151
public:
5252
static MediaPlayerEnums::SupportsType isContentTypeSupported(const ContentType&);
5353

0 commit comments

Comments
 (0)