Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke delegate the stream(_ stream: NetStream, didOutput video: CMSa… #1232

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

shogo4405
Copy link
Owner

…mpleBuffer) method.

Description & motivation

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Screenshots:

@shogo4405 shogo4405 added this to the 1.5.3 milestone Jul 11, 2023
@shogo4405 shogo4405 merged commit a1cc00f into main Jul 11, 2023
1 check passed
@shogo4405 shogo4405 deleted the feature/video-codec-delegate branch July 11, 2023 12:55
@zaliva08
Copy link

After the changes you made, for me still do not work out the delegate and does not come CMSampleBuffer.
override func viewDidLoad() {
super.viewDidLoad()
rtmpConnection.delegate = self
rtmpStream.delegate = self
}
extension MAnchorVC: NetStreamDelegate {
func stream(_ stream: HaishinKit.NetStream, didOutput video: CMSampleBuffer) {
guard !self.isStopped else { return }
XMagicManager.share().processData(withCpuFuc: video)
}

How else can I get CMSampleBuffer ?

@zaliva08
Copy link

Add please delegate?.mixer(self, didOutput: sampleBuffer)
You should do this in func useSampleBuffer

func useSampleBuffer(sampleBuffer: CMSampleBuffer, mediaType: AVMediaType) -> Bool {
    switch mediaSync {
    case .video:
        if mediaType == .audio {
            return !videoTimeStamp.seconds.isZero && videoTimeStamp.seconds <= sampleBuffer.presentationTimeStamp.seconds
        }
        if videoTimeStamp == CMTime.zero {
            videoTimeStamp = sampleBuffer.presentationTimeStamp
        }
        delegate?.mixer(self, didOutput: sampleBuffer)
        return true
    default:
        return true
    }
}

@shogo4405
Copy link
Owner Author

This feature is primarily designed for the behavior during playback and becomes part of the specification.

@zaliva08
Copy link

I had to implement a library of effects. I needed SampleBuffer for this from rtmpStream. By adding this delegate in library I was able to get the result I need.

But I added the library HashimKit as static because of this. It would be nice if you would correct yourself then I will go back to use Cartfile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants