< Previous PageNext Page > Hide TOC

Using Sequence Grabber Channel Components

This chapter gives an overview of the services your channel component needs to provide. Your component will primarily be used to preview and record digital data. Your component must also make calls to application-defined callback functions if so directed. Finally, your component must provide utility functions that will perform default procedures for the application’s callback functions.

In response to application requests, sequence grabber components can use channel components in two ways: to preview digitized data for the user or to record captured data in a QuickTime movie. Applications can use previewing to allow the user to prepare to make a recording. Applications that use previewing can move directly from the preview operation to a record operation, without stopping the process.

The next two sections provide an overview of preview and record operations. A third section discusses the callback functions that are supported by some channel components.

In this section:

Previewing
Configuring Sequence Grabber Channel Components
Controlling Sequence Grabber Channel Components
Recording
Working With Callback Functions
Working With Channel Devices
Utility Functions for Sequence Grabber Channel Components


Previewing

Previewing captured data involves playing that data for the user as it is digitized. For video data, this means displaying the video images on the computer screen. For audio data, this means playing the sound through the computer’s sound system. The following paragraphs outline the steps the sequence grabber component follows to preview captured data.

  1. First, the sequence grab ber component opens a connection to your channel component, using the Component Manager’s OpenComponent function. The sequence grabber component then calls your SGInitChannel function to initialize your component.

  2. The sequence grabber component then configures your channel component for the preview operation. The SGSetGWorld function sets the graphics world in which the preview is to be displayed. The SGSetChannelUsage function specifies that your channel is to be used for previewing. The application can then use the appropriate channel configuration functions to prepare your channel for the preview operation. For video channels, it uses the functions discussed in Configuration Functions for Video Channel Components. For sound channels, the sequence grabber uses the functions discussed in Configuration Functions for Sound Channel Components.

  3. The sequence grabber component starts the preview operation by calling your SGStartPreview function. The sequence grabber component then begins collecting data from all of the channels participating in the preview and plays that data appropriately. The sequence grabber component can pause and restart the preview by calling the SGPause function. The sequence grabber component uses the SGStop function to stop the preview. During the preview operation, the sequence grabber component calls your SGIdle function frequently, so that your channel can perform its operation.

  4. When the application is done previewing, the sequence grabber component can start recording or close its connection to your component.

The following functions allow sequence grabber components to control your channel component:

Configuring Sequence Grabber Channel Components

This section discusses the functions that allow sequence grabber components to configure your channel component.

Sequence grabber components use a number of functions to establish the environment for grabbing or previewing digitized data. This section describes the channel component functions that allow the sequence grabber component to establish the environment for recording or previewing captured data.

The sequence grabber component uses the SGInitChannel function to initialize your channel prior to a record or preview operation.

The SGSetGWorld function allows the sequence grabber component to assign a graphics world to your component.

Configuration Functions for All Channel Components

Your channel is assigned to a sequence grabber component when the application calls the sequence grabber component’s SGNewChannel function, described in the chapter Sequence Grabber Component Functions in this document. The sequence grabber component must configure your channel before a preview or record operation. Your channel component must provide a number of functions that allow the sequence grabber to configure the characteristics of your channel. Several of these functions work on any channel component. This section discusses these general channel configuration functions.

In addition, channel components provide functions that are specific to the channel type. The sequence grabber component supplied by Apple uses two types of channel components: video channel components and sound channel components. See Configuration Functions for Video Channel Components for information about the configuration functions that work only with video channels. See Configuration Functions for Sound Channel Components for information about the configuration functions that work only with sound channels.

Configuration Functions for Video Channel Components

Video channel components provide a number of functions that allow the sequence grabber to configure the channel’s video characteristics. This section describes these video channel configuration functions, which the sequence grabber component uses only with video channels:

Configuration Functions for Sound Channel Components

Sound channel components provide a number of functions that allow sequence grabber components to configure the component’s sound channel. This section describes these sound channel configuration functions. The sequence grabber component uses these functions only with sound channels.

Controlling Sequence Grabber Channel Components

Sequence grabber channel components must provide a full set of functions that allow the sequence grabber component to control the preview or record operation. The sequence grabber component can use these functions to start and stop the operation, to pause data collection, and to write captured data to a movie. This section describes these functions.

Recording

During a record operation, a sequence grabber component collects the data it captures and formats that data into a QuickTime movie. During a record operation, the sequence grabber component can also play the captured data for the user.

The following are the steps the sequence grabber component follows to record captured data.

  1. As with a preview operation, the sequence grabber component establishes a connection to your channel component by calling the Component Manager’s OpenComponent function. It then initializes your component by calling your SGInitChannel function.

  2. The sequence grabber component then configures your component for the record operation. The SGSetGWorld function sets the graphics world in which the data is to be displayed. The SGSetChannelUsage function specifies each channel that is to be used for recording. At this time, the sequence grabber component can also specify whether your component is to play its data while recording. The application can then use the appropriate channel configuration functions to prepare your channel for the record operation. For video channels, it uses the functions discussed in Configuration Functions for Video Channel Components. For sound channels, the sequence grabber uses the functions discussed in Configuration Functions for Sound Channel Components.

  3. The sequence grabber component starts the record operation by calling your SGStartRecord function. The sequence grabber component then begins collecting data from the channels it has assigned, stores the data in a QuickTime movie, and, optionally, plays that data appropriately. The sequence grabber can pause and restart the record process by calling the SGPause function. During the record operation, the sequence grabber component calls your SGIdle function frequently, so that your channel can perform its operation. The sequence grabber component uses the SGStop function to stop the record operation. At this time, your component saves the movie in the appropriate movie file if the sequence grabber component instructs your component to do so by calling your SGWriteSamples function.

  4. When the application is done recording, it either returns to previewing or closes its connection to your component.

Working With Callback Functions

Sequence grabber components provide callback functions that allow application developers to customize some aspects of capturing video data. It is your channel component’s responsibility to call these callback functions at specified points in the data capture process. The application’s function can then perform any special processing that is appropriate for the application. For example, an application can overlay text, such as a frame number, on each frame of video data as it is captured.

Note:  Sound channel components do not support any callback functions.

Using Callback Functions for Video Channel Components

Sequence grabber components allow application developers to define a number of callback functions in their applications. Your channel component calls these functions at specific points in the process of collecting, compressing, and displaying the source visual data. By defining callback functions, a developer can control the process more precisely or customize the operation of the sequence grabber component and its channel components.

For example, you could use a callback function to draw a frame number on each video frame as it is collected. In this case, you could use either a compress callback function or a grab-complete callback function. You call the compress function after each frame is collected, in order to compress the frame. You call the grab-complete function just before the compress function or as soon as the frame has been captured.

Note that your channel component need not call each and every callback function. If some functions are inappropriate to the operation of your channel, do not call them. However, if your component calls one function of a pair, be sure to call the other. For example, if your component calls an application’s grab function, you must also call its grab-complete function.

The sequence grabber component uses the SGSetVideoBottlenecks function to assign callback functions to your video channel. The SGGetVideoBottlenecks function allows the sequence grabber to determine the callback functions that have been assigned to your video channel. See the chapter Sequence Grabber Component Functions in this document for details on SGSetVideoBottlenecks and SGGetVideoBottlenecks.

The following application-defined functions are supported by video channels and are described in Application-Defined Functions.

Using Utility Functions for Video Channel Component Callback Functions

Sequence grabber components provide a number of functions that application-defined functions can use. Several channel functions support those sequence grabber component functions.

The sequence grabber component uses the SGGetBufferInfo function to obtain information about a buffer that contains data to be manipulated by a callback function. Application callback functions can use the SGGetBufferInfo function to obtain information about a buffer that you have passed. This information is valid only during record operations, or after your channel has been prepared to record. The SGGetBufferInfo function is described in the chapter Sequence Grabber Component Functions.

The following functions provide default behavior for application-defined grab, grab-complete, display, compress, compress-complete, add-frame, transfer-frame, display-compress, and grab-compress-complete functions:

Working With Channel Devices

Sequence grabbers provide a number of functions that allow applications to determine the devices that can be, or the device that is, attached to a given sequence grabber channel. These devices, in turn, allow the channel component to control the digitizing equipment. For example, video channels use video digitizer components, and sound channels use sound input drivers. Applications can use these functions to present a list of available devices to the user, allowing the user to select a specific device for each channel. The sequence grabber passes these functions on to your channel component.

The sequence grabber may use the SGGetChannelDeviceList function to retrieve a list of devices that may be used by your channel.

The sequence grabber can use the SGSetChannelDevice function to assign a device to your channel.

The SGGetChannelDeviceList function uses a device list structure to pass information about one or more channel devices. The SGDeviceListRecord data type defines the format of the device list structure.

typedef struct SGDeviceListRecord {
    short               count;                  /* count of devices */
    short               selectedIndex;          /* current device */
    long                reserved;               /* set to 0 */
    SGDeviceName        entry[1];               /* device names */
} SGDeviceListRecord, *SGDeviceListPtr, **SGDeviceList;

Field

Description

count

Indicates the number of devices described by this structure. The value of this field corresponds to the number of entries in the device name array defined by the entry field.

selectedIndex

Identifies the currently active device. The value of this field corresponds to the appropriate entry in the device name array defined by the entry field. Note that this value is 0-relative; that is, the first entry has an index number of 0, the second's value is 1, and so on.

reserved

Reserved for Apple. Always set to 0.

entry

Contains an array of device name structures. Each structure corresponds to one valid device. The count field indicates the number of entries in this array. The SGDeviceName data type defines the format of a device name structure; this data type is discussed next.

Device list structures contain an array of device name structures. Each device name structure identifies a single device that may be used by the channel. The SGDeviceName data type defines the format of a device name structure.

typedef struct SGDeviceName {
    Str63           name;                   /* device name */
    Handle          icon;                   /* device icon */
    long            flags;                  /* flags */
    long            refCon;                 /* set to 0 */
    long            reserved;               /* set to 0 */
} SGDeviceName;

Parameter

Description

name

Contains the name of the device. For video digitizer components, this field contains the component's name as specified in the component resource. For sound input drivers, this field contains the driver name.

icon

Contains a handle to the device's icon. Some devices may support an icon, which applications may choose to present to the user. If the device does not support an icon, or if the sequence grabber chooses not to retrieve this information (by setting the sgDeviceListWithIcons flag to 0 when it calls the SGGetChannelDeviceList function), set this field to nil.

flags

Reflects the current status of the device. The sgDeviceNameFlagDeviceUnavailable flag is defined. When set to 1, this flag indicates that this device is not currently available.

refCon

Reserved for Apple. Always set to 0.

reserved

Reserved for Apple. Always set to 0.

Utility Functions for Sequence Grabber Channel Components

This section describes several utility functions that sequence grabber components provide to sequence grabber channel components.

struct SeqGrabFrameInfo {
    long            frameOffset;        /* offset to the sample */
    long            frameTime;          /* time that frame was captured */
    long            frameSize;          /* number of bytes in sample */
    SGChannel       frameChannel;       /* current connection to channel */
    long            frameRefCon;        /* reference constant for channel */
};

Field

Description

frameOffset

Specifies the offset to the sample. Your channel component obtains this value from the SGWriteMovieData function.

frameTime

Specifies the time at which your channel component captured the frame. This time value is relative to the data sequence. That is, this time is not represented in the context of any fixed time scale. Rather, your channel component must choose and use a time scale consistently for all sample references.

frameSize

Specifies the number of bytes in the sample described by the sample reference.

frameChannel

Identifies the current connection to your channel.

frameRefCon

Contains a reference constant for use by your channel component. You can use this value in any way that is appropriate for your channel component. For example, video channel components may use this value to store a reference to frame differencing information for a temporally compressed image sequence.



< Previous PageNext Page > Hide TOC


© 2005, 2007 Apple Inc. All Rights Reserved. (Last updated: 2007-01-08)


Did this document help you?
Yes: Tell us what works for you.
It’s good, but: Report typos, inaccuracies, and so forth.
It wasn’t helpful: Tell us what would have helped.