Hello
Thank you for your response !
I have tried below solution and also resolved crash , but I m not able to send video still because - ACSRawOutgoingVideoStream not getting any method to initialise it
import UIKit
import AzureCommunicationCalling
class ScreenShareManager {
**var outgoingVideoStream: ACSOutgoingVideoStream?**
**func startScreenSharing() {**
**let localVideoStream = try? LocalVideoStream(videoStream: outgoingVideoStream)**
**// Assuming you have a call instance**
**call?.startVideo(streams: [localVideoStream])**
**}**
**func receiveFrame(pixelBuffer: CVPixelBuffer) {**
**// Convert CVPixelBuffer to ACSOutgoingVideoStream frame**
**outgoingVideoStream?.send(pixelBuffer)**
**}**
**}
below is my sample code
**
private func SendRawVideoFrame()->Void{
// Lock Pixel Buffer
guard let buffer = self.loadPixelBuffer() else {
print("❌ Failed to load pixel buffer.")
return
}
// Lock Pixel Buffer
CVPixelBufferLockBaseAddress(buffer, .readOnly)
let width = CVPixelBufferGetWidth(buffer)
let height = CVPixelBufferGetHeight(buffer)
print()
let actualStride1 = CVPixelBufferGetBytesPerRowOfPlane(buffer, 0)
let actualStride2 = CVPixelBufferGetBytesPerRowOfPlane(buffer, 1)
let expectedSize = (CVPixelBufferGetWidth(buffer) * CVPixelBufferGetHeight(buffer)) + (CVPixelBufferGetWidth(buffer) * CVPixelBufferGetHeight(buffer) / 2)
// Unlock Pixel Buffer
CVPixelBufferUnlockBaseAddress(buffer, .readOnly)
// Debugging stride values
print("📏 Width: (width), Height: (height) Expected size: (expectedSize)")
print("🖼 Stride1: (actualStride1), Stride2: (actualStride2/2)")
// Create VideoStreamFormat
let videoStreamFormat = VideoStreamFormat()
videoStreamFormat.width = Int32(width)
videoStreamFormat.height = Int32(height)
videoStreamFormat.pixelFormat = VideoStreamPixelFormat.rgba
videoStreamFormat.framesPerSecond = 7.5
videoStreamFormat.stride1 = Int32(actualStride1) * 4
//videoStreamFormat.stride2 = Int32(actualStride2/2)
var videoStreamFormats: [VideoStreamFormat] = VideoStreamFormat
videoStreamFormats.append(videoStreamFormat)
// Set up outgoing video stream options
outgoingVideoStreamOptions = RawOutgoingVideoStreamOptions()
outgoingVideoStreamOptions.formats = videoStreamFormats
print("✅ outgoingVideoStreamOptions Stream Format Set: (outgoingVideoStreamOptions.formats)")
// Initialize Outgoing Video Stream
rawOutgoingVideoStream = ScreenShareOutgoingVideoStream(videoStreamOptions: outgoingVideoStreamOptions)
// Check if format is properly set
if let format = rawOutgoingVideoStream?.format {
print("✅ Video Stream Format Set: (format)")
} else {
print("❌ Error: rawOutgoingVideoStream.format is nil! (rawOutgoingVideoStream?.format)")
}
// Ensure the stream is started before sending frames
if rawOutgoingVideoStream?.state != .started {
print("❌ Outgoing video stream is not started yet. Retrying in 1 second...")
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
//self.trySendingFrameAgain()
}
return
}
// Prepare Video Frame
let videoFrameBuffer = RawVideoFrameBuffer()
videoFrameBuffer.buffer = buffer
videoFrameBuffer.streamFormat = videoStreamFormat
// Send Frame
rawOutgoingVideoStream?.send(frame: videoFrameBuffer) { error in
if let error = error {
print("❌ Error sending frame: (error.localizedDescription)")
} else {
print("✅ Frame sent successfully!")
}
}
}
Outgoingvideostream always getting not started and also format is nil
Can you help me here what I m doing wrong ?
Thank you.