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

Issue that does not publish sample buffers when used only audio #1027

Closed
Jellabean07 opened this issue Jul 11, 2022 · 3 comments
Closed

Issue that does not publish sample buffers when used only audio #1027

Jellabean07 opened this issue Jul 11, 2022 · 3 comments
Labels
Milestone

Comments

@Jellabean07
Copy link

Describe the bug

  • If audio is used only, captureOutput cannot send a sample buffer because AVMixer's useSampleBuffer function always returns false.
  • The reason is that MediaSync is always fixed with video when only attachAudio is called
  • Therefore, exception handling is required for audio only
func captureOutput(_ output: AVCaptureOutput, didOutput sampleBuffer: CMSampleBuffer, from connection: AVCaptureConnection) {
        
        guard mixer?.useSampleBuffer(sampleBuffer: sampleBuffer, mediaType: AVMediaType.audio) == true else {
            return
        }
        appendSampleBuffer(sampleBuffer)
    }
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
            }
            return true
        case .audio:
            if mediaType == .video {
                return !audioTimeStamp.seconds.isZero && audioTimeStamp.seconds <= sampleBuffer.presentationTimeStamp.seconds
            }
            if audioTimeStamp == CMTime.zero {
                audioTimeStamp = sampleBuffer.presentationTimeStamp
            }
            return true
        default:
            return true
        }
    }

To Reproduce

Use only the attachAudio function and do not use attachVideo.

Expected behavior

The sample buffer should be published when using audio only

Version

1.2.6

Smartphone info.

No response

Additional context

No response

Screenshots

No response

Relevant log output

No response

@shogo4405 shogo4405 added this to the 1.2.7 milestone Jul 11, 2022
@shogo4405 shogo4405 added the bug label Jul 11, 2022
shogo4405 added a commit that referenced this issue Jul 11, 2022
@shogo4405
Copy link
Owner

Thank you for feedback. I fixed it cd57a82.

@Jellabean07
Copy link
Author

@shogo4405 Thank you for fixed it
I'll look forward to the version being updated

@shogo4405
Copy link
Owner

closed as fixed and released 1.2.7

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants