Inherits from | |
Conforms to | |
Framework | /System/Library/Frameworks/QTKit.framework |
Availability | Available in QuickTime 7.2.1 and later; QuickTime 7.2.1. |
Declared in | QTCaptureConnection.h |
Related sample code |
This class represents a connection over which a single stream of media data is sent from a QTCaptureInput
to a QTCaptureSession
and from a QTCaptureSession
to a QTCaptureOutput
.
Instances of QTCaptureConnection
wrap individual media streams that can be provided by QTCaptureInput
objects and received by QTCaptureOutput
objects. Connections can have a QuickTime media type, such as QTMediaTypeVideo
and QTMediaTypeSound
, and a format description that describes the media sent or received across the connection. Individual connections belonging to an input can be enabled or disabled to restrict what media enters a capture session, while connections belonging to an output can be enabled or disabled to restrict what media enters the output from the capture session. In addition, if a QTCaptureConnection
wraps a stream of audio media, it provides a number of attributes to control the volume, mix, and enabled channels of the audio passing through it.
QTCaptureConnection
objects can have extended attributes that applications can read using the attributeForKey:
and connectionAttributes
methods. Some attributes, for which the attributeIsReadOnly:
method returns NO
, can be edited using the setAttribute:forKey:
and setConnectionAttributes:
methods. In addition to these explicit methods, applications can use key-value coding to get and set extended attributes. For an object that supports a given attribute, valueForKey:
will be functionally identical to attributeForKey:
, and setValue:forKey:
will be identical to setAttribute:forKey:
. Applications wishing to observe changes for a given attribute can add a key-value observer where the key path is the attribute key.
– attributeForKey:
– attributeIsReadOnly:
– connectionAttributes
– formatDescription
– isEnabled
– mediaType
– owner
– setAttribute:forKey:
– setConnectionAttributes:
– setEnabled:
Returns the current value of the connection attribute for key.
- (id)attributeForKey:(NSString *)attributeKey
Use this method to get attributes of a connection. The keys that can be used with this method are described in the Constants section. Applications using key-value coding can also get an attribute for a given key by passing that key to the NSObject valueForKey:
method.
QTCaptureConnection.h
Returns a Boolean value indicating whether the given attribute for the connection cannot be modified.
- (BOOL)attributeIsReadOnly:(NSString *)attributeKey
Returns YES
if the attribute cannot be modified; otherwise, NO
.
QTCaptureConnection.h
Returns a dictionary of all attributes set for the receiver.
- (NSDictionary *)connectionAttributes
Applications can use this method to determine what attributes a specific connection supports.
QTCaptureConnection.h
Returns the format description of the receiver.
- (QTFormatDescription *)formatDescription
This method returns the format description of the connection, allowing applications to monitor various attributes of the media being sent or received by the connection (the display size of video media, for example). Applications can be notified of changes to the connection’s format by registering to receive QTCaptureConnectionFormatDescriptionWillChangeNotification
and QTCaptureConnectionFormatDescriptionDidChangeNotification
notifications or by adding a key-value observer to the connection for the key @"formatDescription"
.
QTCaptureConnection.h
Returns a Boolean value indicating whether the receiver is enabled.
- (BOOL)isEnabled
This method returns a Boolean indicating whether the receiver is enabled to send or receive media data. Individual connections can be enabled or disabled using the setEnabled:
method.
QTCaptureConnection.h
Returns the QuickTime media type of the receiver.
- (NSString *)mediaType
A QuickTime media type, as defined in QTMedia.h
.
This method returns the QuickTime media type, such as QTMediaTypeVideo
and QTMediaTypeSound
, of the receiver.
QTCaptureConnection.h
Returns the QTCaptureInput
or QTCaptureOutput
object that owns the receiver.
- (id)owner
A QTCaptureInput
or QTCaptureOutput
object that uses the receiver as a media connection.
This method returns the input or output to which the receiver belongs. The returned input or output uses the receiver as a connection for sending or receiving a media stream.
QTCaptureConnection.h
Sets a connection attribute for the given key.
- (void)setAttribute:(id)attribute forKey:(NSString *)key
Use this method to set attributes of a capture connection. The keys that can be used with this method are described in the Constants section. This method raises an NSInvalidArgumentException if the attribute is read-only or not supported by the receiver. Applications using key-value coding can also set an attribute for a given key by passing that key to the NSObject setValue:forKey:
method.
QTCaptureConnection.h
Sets the connection’s attributes from the key-value pairs specified in the given dictionary.
- (void)setConnectionAttributes:(NSDictionary *)connectionAttributes
This method allows application to set multiple attributes on a connection at once. This method raises an NSInvalidArgumentException if any of the attributes in the dictionary are read-only or not supported by the receiver. Applications using key-value coding can also set multiple attributes using the NSObject setValuesForKeysWithDictionary:
method using attribute keys as keys in the dictionary.
QTCaptureConnection.h
Sets whether the receiver is enabled.
- (void)setEnabled:(BOOL)enabled
This method sets whether the receiver is enabled to send or receive media data.
QTCaptureConnection.h
Applications can use the following constants to display audio level meters for specific connections and to specify the volumes of audio channels. These string values can be used in key paths for key-value coding, key-value observing, and bindings.
NSString * const QTCaptureConnectionAudioAveragePowerLevelsAttribute; NSString * const QTCaptureConnectionAudioPeakHoldLevelsAttribute; NSString * const QTCaptureConnectionAudioMasterVolumeAttribute; NSString * const QTCaptureConnectionAudioVolumesAttribute; NSString * const QTCaptureConnectionEnabledAudioChannelsAttribute;
QTCaptureConnectionAudioAveragePowerLevelsAttribute
An NSArray
of NSNumbers
that correspond to the average power, in decibels, of each audio stream sent through the connection.
Applications that wish to display audio level meters for a specific connection can periodically check the value of this attribute. Average power levels change quickly and appear jumpy on a level meter. This string value can be used in key paths for key-value coding, key-value observing, and bindings.
Available in Mac OS X v10.5 and later.
Declared in QTCaptureConnection.h
.
QTCaptureConnectionAudioPeakHoldLevelsAttribute
An NSArray
of NSNumbers
that correspond to the peak hold level, in decibels, of each audio channel sent through the connection.
Applications that wish to display audio level meters for a specific connection can periodically check the value of this attribute. Peak hold levels remain at the maximum volume for about a second, and are often useful for displaying audio clipping. This string value can be used in key paths for key-value coding, key-value observing, and bindings.
Available in Mac OS X v10.5 and later.
Declared in QTCaptureConnection.h
.
QTCaptureConnectionAudioMasterVolumeAttribute
An NSNumber
that specifies the master volume of all audio channels sent through the connection.
The values are between 0.0 and 1.0 for normal volume, or greater than 1.0 for boosting the audio gain. This attribute determines the master volumes of all audio channels sent through the connection. Applications that need to set the volumes of individual channels can set the QTCaptureConnectionAudioVolumesAttribute
attribute. This string value can be used in key paths for key-value coding, key-value observing, and bindings.
Available in Mac OS X v10.5 and later.
Declared in QTCaptureConnection.h
.
QTCaptureConnectionAudioVolumesAttribute
An NSArray
of NSNumbers
that specify the volumes of audio channels sent through the connection.
The values are between 0.0 and 1.0 for normal volume, or greater than 1.0 for boosting the audio gain. This attribute determines the individual volumes of audio channels sent through the connection. Applications that need to set the master volume of all channels can set the QTCaptureConnectionAudioMasterVolumeAttribute
attribute. This string value can be used in key paths for key-value coding, key-value observing, and bindings.
Available in Mac OS X v10.5 and later.
Declared in QTCaptureConnection.h
.
QTCaptureConnectionEnabledAudioChannelsAttribute
An NSIndexSet
that specifies which audio channels should be sent through the connection. The indices in the set should be between 0 and the number of volumes in QTCaptureConnectionAudioVolumesAttribute
. This attribute allows applications to selectively disable certain audio channels from being sent through the connection. The value of this attribute should be an NSIndexSet
that contains only the channels that should be used. By default, all audio channels are sent though a connection. This string value can be used in key paths for key-value coding, key-value observing, and bindings.
Available in Mac OS X v10.5 and later.
Declared in QTCaptureConnection.h
.
The following are notifications enabling you to change attributes, keys, and format descriptions.
Posted when one of the connection’s attributes has changed.
The notification’s user info dictionary will contain the attribute key of the changed attribute for the key
QTCaptureConnectionChangedAttributeKey
.
QTCaptureConnection.h
Posted when one of the connection’s attributes is about to change.
The notification’s user info dictionary will contain the attribute key of the changed attribute for the key
QTCaptureConnectionChangedAttributeKey
.
QTCaptureConnection.h
Used as a key in the user info dictionary passed to QTCaptureConnectionAttributeWillChangeNotification
, and QTCaptureConnectionAttributeDidChangeNotification
to indicate the key of that attribute that changed.
QTCaptureConnection.h
Posted when the format description of a connection has changed.
Applications can be notified of changes to a connection’s format by registering to receive this notification.
QTCaptureConnection.h
Posted when the format description of a connection is about to change.
Applications can be notified of changes to a connection’s format by registering to receive this notification.
QTCaptureConnection.h
© 2009 Apple Inc. All Rights Reserved. (Last updated: 2009-05-06)