AVCaptureSession

AVFoundation捕捉的核心是AVCaptureSession,官方文檔的描述是<code>You use an AVCaptureSession object to coordinate the flow of data from AV input devices to outputs.</code>,可以有多個輸入或輸出郭卫。它是連接AVCaptureInput和AVCaptureOutput的橋梁,它協(xié)調(diào)input到output之間傳輸數(shù)據(jù)铲汪。
初始化方法

   AVCaptureSession *seesion = [[AVCaptureSession alloc] init];
    seesion.sessionPreset = AVCaptureSessionPresetHigh;

屬性

/*!
 @property sessionPreset
 @abstract
    Indicates the session preset currently in use by the receiver.
 
 @discussion
    The value of this property is an NSString (one of AVCaptureSessionPreset*) indicating 
    the current session preset in use by the receiver.  The sessionPreset property may be set 
    while the receiver is running.
*/
@property(nonatomic, copy) NSString *sessionPreset;```

默認值是<code>
AVCaptureSessionPresetHigh</code>

當然還有其他值

AVCaptureSessionPreset1280x720
AVCaptureSessionPreset1920x1080
AVCaptureSessionPreset352x288
AVCaptureSessionPreset640x480
AVCaptureSessionPresetInputPriority
AVCaptureSessionPresetLow
AVCaptureSessionPresetMedium
AVCaptureSessionPresetPhoto
AVCaptureSessionPresetiFrame1280x720
AVCaptureSessionPresetiFrame960x540


![Paste_Image.png](http://upload-images.jianshu.io/upload_images/1643663-52024bd809520a33.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)


##一些方法
若想在一個已經(jīng)使用上的session中(已經(jīng)startRunning了)做更換新的device、刪除舊的device等一系列操作塑悼,(比如可以通過調(diào)用下面兩個方法切換手機的攝像頭操作)那么就需要使用如下方法:

/*!
@method beginConfiguration
@abstract
When paired with commitConfiguration, allows a client to batch multiple configuration
operations on a running session into atomic updates.

@discussion
-beginConfiguration / -commitConfiguration are AVCaptureSession's mechanism
for batching multiple configuration operations on a running session into atomic
updates. After calling [session beginConfiguration], clients may add or remove
outputs, alter the sessionPreset, or configure individual AVCaptureInput or Output
properties. All changes will be pended until the client calls [session commitConfiguration],
at which time they will be applied together. -beginConfiguration / -commitConfiguration
pairs may be nested, and will only be applied when the outermost commit is invoked.
*/

  • (void)beginConfiguration;

/*!
@method commitConfiguration
@abstract
When preceded by beginConfiguration, allows a client to batch multiple configuration
operations on a running session into atomic updates.
*/

  • (void)commitConfiguration;

/*!
@method stopRunning
@abstract
Starts an AVCaptureSession instance running
*/

  • (void)startRunning;

/*!
@method stopRunning
@abstract
Stops an AVCaptureSession instance that is currently running.
*/

  • (void)stopRunning;
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市楷掉,隨后出現(xiàn)的幾起案子厢蒜,更是在濱河造成了極大的恐慌,老刑警劉巖靖诗,帶你破解...
    沈念sama閱讀 216,402評論 6 499
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件郭怪,死亡現(xiàn)場離奇詭異,居然都是意外死亡刊橘,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,377評論 3 392
  • 文/潘曉璐 我一進店門颂鸿,熙熙樓的掌柜王于貴愁眉苦臉地迎上來促绵,“玉大人,你說我怎么就攤上這事嘴纺“芮纾” “怎么了?”我有些...
    開封第一講書人閱讀 162,483評論 0 353
  • 文/不壞的土叔 我叫張陵栽渴,是天一觀的道長尖坤。 經(jīng)常有香客問我,道長闲擦,這世上最難降的妖魔是什么慢味? 我笑而不...
    開封第一講書人閱讀 58,165評論 1 292
  • 正文 為了忘掉前任,我火速辦了婚禮墅冷,結(jié)果婚禮上纯路,老公的妹妹穿的比我還像新娘。我一直安慰自己寞忿,他們只是感情好驰唬,可當我...
    茶點故事閱讀 67,176評論 6 388
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著腔彰,像睡著了一般叫编。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上霹抛,一...
    開封第一講書人閱讀 51,146評論 1 297
  • 那天搓逾,我揣著相機與錄音,去河邊找鬼上炎。 笑死恃逻,一個胖子當著我的面吹牛雏搂,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播寇损,決...
    沈念sama閱讀 40,032評論 3 417
  • 文/蒼蘭香墨 我猛地睜開眼凸郑,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了矛市?” 一聲冷哼從身側(cè)響起芙沥,我...
    開封第一講書人閱讀 38,896評論 0 274
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎浊吏,沒想到半個月后而昨,有當?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,311評論 1 310
  • 正文 獨居荒郊野嶺守林人離奇死亡找田,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,536評論 2 332
  • 正文 我和宋清朗相戀三年歌憨,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片墩衙。...
    茶點故事閱讀 39,696評論 1 348
  • 序言:一個原本活蹦亂跳的男人離奇死亡务嫡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出漆改,到底是詐尸還是另有隱情心铃,我是刑警寧澤,帶...
    沈念sama閱讀 35,413評論 5 343
  • 正文 年R本政府宣布挫剑,位于F島的核電站去扣,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏樊破。R本人自食惡果不足惜愉棱,卻給世界環(huán)境...
    茶點故事閱讀 41,008評論 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望捶码。 院中可真熱鬧羽氮,春花似錦、人聲如沸惫恼。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,659評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽祈纯。三九已至令宿,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間腕窥,已是汗流浹背粒没。 一陣腳步聲響...
    開封第一講書人閱讀 32,815評論 1 269
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留簇爆,地道東北人癞松。 一個月前我還...
    沈念sama閱讀 47,698評論 2 368
  • 正文 我出身青樓爽撒,卻偏偏與公主長得像,于是被迫代替她去往敵國和親响蓉。 傳聞我的和親對象是個殘疾皇子硕勿,可洞房花燭夜當晚...
    茶點故事閱讀 44,592評論 2 353

推薦閱讀更多精彩內(nèi)容