Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
Material
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitriy Stepanets
Material
Commits
081bd66b
Commit
081bd66b
authored
Dec 02, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update CaptureSession internals
parent
a53a6fe5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
18 deletions
+17
-18
Source/CaptureSession.swift
+17
-18
No files found.
Source/CaptureSession.swift
View file @
081bd66b
...
@@ -49,16 +49,6 @@ public class CaptureSession : NSObject {
...
@@ -49,16 +49,6 @@ public class CaptureSession : NSObject {
private
lazy
var
videoQueue
:
dispatch_queue_t
=
dispatch_queue_create
(
"io.materialkit.CaptureSession"
,
nil
)
private
lazy
var
videoQueue
:
dispatch_queue_t
=
dispatch_queue_create
(
"io.materialkit.CaptureSession"
,
nil
)
//
//
// :name: videoDevice
//
private
lazy
var
videoDevice
:
AVCaptureDevice
=
AVCaptureDevice
.
defaultDeviceWithMediaType
(
AVMediaTypeVideo
)
//
// :name: audioDevice
//
private
lazy
var
audioDevice
:
AVCaptureDevice
=
AVCaptureDevice
.
defaultDeviceWithMediaType
(
AVMediaTypeAudio
)
//
// :name: activeVideoInput
// :name: activeVideoInput
//
//
private
var
activeVideoInput
:
AVCaptureDeviceInput
?
private
var
activeVideoInput
:
AVCaptureDeviceInput
?
...
@@ -134,22 +124,31 @@ public class CaptureSession : NSObject {
...
@@ -134,22 +124,31 @@ public class CaptureSession : NSObject {
}
}
/**
/**
:name: cameraSupportsTapToFocus
*/
public
var
cameraSupportsTapToFocus
:
Bool
{
return
true
}
/**
:name: focusMode
:name: focusMode
*/
*/
public
var
focusMode
:
AVCaptureFocusMode
{
public
var
focusMode
:
AVCaptureFocusMode
{
get
{
get
{
return
videoDevice
.
focusMode
return
activeCamera
!
.
focusMode
}
}
set
(
value
)
{
set
(
value
)
{
var
error
:
NSError
?
var
error
:
NSError
?
if
isFocusModeSupported
(
focusMode
)
{
if
isFocusModeSupported
(
focusMode
)
{
do
{
do
{
try
videoDevice
.
lockForConfiguration
()
let
device
:
AVCaptureDevice
=
activeCamera
!
videoDevice
.
focusMode
=
focusMode
try
device
.
lockForConfiguration
()
videoDevice
.
unlockForConfiguration
()
device
.
focusMode
=
focusMode
device
.
unlockForConfiguration
()
}
catch
let
e
as
NSError
{
}
catch
let
e
as
NSError
{
error
=
e
error
=
e
}
}
}
else
{
error
=
NSError
(
domain
:
"[MaterialKit Error: Unsupported focusMode.]"
,
code
:
0
,
userInfo
:
nil
)
error
=
NSError
(
domain
:
"[MaterialKit Error: Unsupported focusMode.]"
,
code
:
0
,
userInfo
:
nil
)
}
}
if
let
e
:
NSError
=
error
{
if
let
e
:
NSError
=
error
{
...
@@ -223,14 +222,14 @@ public class CaptureSession : NSObject {
...
@@ -223,14 +222,14 @@ public class CaptureSession : NSObject {
:name: isFocusModeSupported
:name: isFocusModeSupported
*/
*/
public
func
isFocusModeSupported
(
focusMode
:
AVCaptureFocusMode
)
->
Bool
{
public
func
isFocusModeSupported
(
focusMode
:
AVCaptureFocusMode
)
->
Bool
{
return
videoD
evice
.
isFocusModeSupported
(
focusMode
)
return
activeVideoInput
!.
d
evice
.
isFocusModeSupported
(
focusMode
)
}
}
/**
/**
:name: isExposureModeSupported
:name: isExposureModeSupported
*/
*/
public
func
isExposureModeSupported
(
exposureMode
:
AVCaptureExposureMode
)
->
Bool
{
public
func
isExposureModeSupported
(
exposureMode
:
AVCaptureExposureMode
)
->
Bool
{
return
videoD
evice
.
isExposureModeSupported
(
exposureMode
)
return
activeVideoInput
!.
d
evice
.
isExposureModeSupported
(
exposureMode
)
}
}
//
//
...
@@ -248,7 +247,7 @@ public class CaptureSession : NSObject {
...
@@ -248,7 +247,7 @@ public class CaptureSession : NSObject {
//
//
private
func
prepareVideoInput
()
{
private
func
prepareVideoInput
()
{
do
{
do
{
activeVideoInput
=
try
AVCaptureDeviceInput
(
device
:
videoDevice
)
activeVideoInput
=
try
AVCaptureDeviceInput
(
device
:
AVCaptureDevice
.
defaultDeviceWithMediaType
(
AVMediaTypeVideo
)
)
if
session
.
canAddInput
(
activeVideoInput
)
{
if
session
.
canAddInput
(
activeVideoInput
)
{
session
.
addInput
(
activeVideoInput
)
session
.
addInput
(
activeVideoInput
)
}
}
...
@@ -262,7 +261,7 @@ public class CaptureSession : NSObject {
...
@@ -262,7 +261,7 @@ public class CaptureSession : NSObject {
//
//
private
func
prepareAudioInput
()
{
private
func
prepareAudioInput
()
{
do
{
do
{
activeAudioInput
=
try
AVCaptureDeviceInput
(
device
:
audioDevice
)
activeAudioInput
=
try
AVCaptureDeviceInput
(
device
:
AVCaptureDevice
.
defaultDeviceWithMediaType
(
AVMediaTypeAudio
)
)
if
session
.
canAddInput
(
activeAudioInput
)
{
if
session
.
canAddInput
(
activeAudioInput
)
{
session
.
addInput
(
activeAudioInput
)
session
.
addInput
(
activeAudioInput
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment