Using Views as Video Data Sources
NSView object can also be a video data source of an
IMAVManager object. This includes instances of the
QTMovieView classes. For example, you can implement a simple web browser using the Web Kit and send the rendered pages to iChat Theater. The Instant Message framework adds video rendering capabilities to these classes. This article explains how to use this feature.
Setting the Video Data Source
It’s very simple to set an
NSView object as a video data source. Just create an instance of the view you want to render as an auxiliary video source in iChat Theater and set the shared
IMAVManager object’s video data source to the view as in this code fragment:
[[IMAVManager sharedAVManager] setVideoDataSource:myWebView];
Setting Video Options for Views
By default, the Instant Message framework uses full-motion video for views. If your content is mostly static, you can improve performance by setting the video optimization options for arbitrary views to stills. If your content is full-motion video, then setting this option has a negative impact on performance.
If you set the video optimization to
IMVideoOptimizationStills using the
setVideoOptimizationOptions: method, you need to tell the Instant Message framework when to request the next frame. If you send
setNeedsDisplayInRect: to an
NSView object, passing
YES as the parameter, then the Instant Message framework requests the next frame.
You do not need to set the optimization options for a
When using this feature, the Instant Message framework doesn’t know the characteristics of the video source—specifically, the rendering methods can’t guess whether the next frame is the same as the previous frame and return
NO to improve performance. Therefore, if performance becomes an issue, create your own video data source.
You can create a subclass of
NSView that does not use the default rendering implementation provided by the Instant Message framework. You can do this by simply implementing the
IMVideoDataSource protocol as explained in Implementing the Video Data Source. The Instant Message framework uses the
NSView subclass implementation of the
IMVideoDataSource rendering methods if they exist.
If you implement your own rendering methods, make sure you use good HiDPI programming practices so your rendering scales correctly into variable-resolution buffers. Read Resolution Independence Guidelines for more information on implementing resolution-independent