2

I am facing a strange crash at

 VTCompressionSessionEncodeFrame(session, (CVPixelBufferRef)data, pts, dur, frameProps, NULL, &flags);

for the following code.

  void H264Encode::pushBuffer(const uint8_t *const data, size_t size, videocore::IMetadata &metadata)
{
    if(m_compressionSession) {
        m_encodeMutex.lock();
        VTCompressionSessionRef session = (VTCompressionSessionRef)m_compressionSession;

        CMTime pts = CMTimeMake(metadata.timestampDelta + m_ctsOffset, 1000.); // timestamp is in ms.
        CMTime dur = CMTimeMake(1, m_fps);
        VTEncodeInfoFlags flags;


        CFMutableDictionaryRef frameProps = NULL;

        if(m_forceKeyframe) {
            s_forcedKeyframePTS = pts.value;

            frameProps = CFDictionaryCreateMutable(kCFAllocatorDefault, 1,&kCFTypeDictionaryKeyCallBacks,                                                            &kCFTypeDictionaryValueCallBacks);


            CFDictionaryAddValue(frameProps, kVTEncodeFrameOptionKey_ForceKeyFrame, kCFBooleanTrue);
        }

        VTCompressionSessionEncodeFrame(session, (CVPixelBufferRef)data, pts, dur, frameProps, NULL, &flags);

        if(m_forceKeyframe) {
            CFRelease(frameProps);
            m_forceKeyframe = false;
        }

        m_encodeMutex.unlock();
    }

What i am trying to do is convert the CVPixelBufferRef to h264 video data. But it always crash at the above mentioned function with EXEC_BAD_ACCESS.

The crash log which appears on the xcode console is something like this..

  Method cache corrupted. This may be a message to an invalid object, or a       memory error somewhere else.
  objc[29576]: receiver 0x10d2077c8, SEL 0x103734801, isa 0x600000123a20,      cache 0x600000123a30, buckets 0x600000123a40, mask 0x0, occupied 0x0
  objc[29576]: receiver 0 bytes, buckets 0 bytes
  objc[29576]: selector '_cfTypeID'
  objc[29576]: isa '  UH\211\345H\213G]\303UH\211\345SP\211\363\350\376\355\377\377\271\373\345\377\377H\205\300tH\213\204\333\225\302\266\362\272'
  objc[29576]:Method cache corrupted.

Does anyone has an idea why it is crashing and a possible fix for this. Any hint or guidance may be helpful..

Dinesh
  • 929
  • 7
  • 25

0 Answers0