0

I am new to twilio and i am trying to add a subview to localVideoTrack in quickstart tutorial, the UIView is getting added to the renderer being shown on mobile but not to the localVideoTrack and is not transmitted to the other user. Please can anyone guide me through here ? I checked on internet but there was not material to help out if i want to add a mask or UIView to the Captured view from camera and send it over mobile. Thank you in advance.

UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mask.png"]];

imageView.bounds = self.camera.previewView.bounds;
[self.camera.previewView addSubview:imageView];


imageView.bounds = self.previewView.bounds;
[self.previewView addSubview:imageView];

self.localVideoTrack = [TVILocalVideoTrack trackWithCapturer:self.camera];

if (!self.localVideoTrack) {
    [self logMessage:@"Failed to add video track"];
} else {
    // Add renderer to video track for local preview
    [self.localVideoTrack addRenderer:self.previewView];

}
Hadi
  • 307
  • 6
  • 20

1 Answers1

1

Twilio developer evangelist here.

When you add a subview to the localVideoTrack you are only working with UIViews on the host device, not directly with the video stream, so it won't appear on the other end.

To me, it seems you have two options. You can either try to intercept the video stream itself, between the camera and the Twilio SDK and alter the video stream itself on the fly. You might need to implement your own TVIVideoCapturer for this.

Alternatively, you could share whatever you want to display over the video to the other side of the connection outside of the video stream itself. You could achieve this using Twilio Sync to share the state, and implement the overlay in the same way you are doing right now with the track renderer.

Let me know if that helps at all.

philnash
  • 70,667
  • 10
  • 60
  • 88
  • Thank you for the answer, it helped me out a lot.. especially guided me through it. – Hadi Jun 20 '17 at 22:34