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
47e5a079
Commit
47e5a079
authored
Nov 22, 2015
by
Daniel Dahan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated Capture code
parent
dafbde3d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
169 additions
and
87 deletions
+169
-87
MaterialKit.xcodeproj/project.pbxproj
+4
-4
Source/CapturePreviewView.swift
+3
-2
Source/CaptureSession.swift
+162
-0
Source/MaterialCapture.swift
+0
-81
No files found.
MaterialKit.xcodeproj/project.pbxproj
View file @
47e5a079
...
...
@@ -72,7 +72,7 @@
9699879C1BC5FE49006D678E
/* MaterialTextLayer.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9699879B1BC5FE49006D678E
/* MaterialTextLayer.swift */
;
};
96C4FABE1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96C4FABD1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift */
;
};
96D26BFD1BC23649006478BD
/* ImageCardView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
;
};
96DF18211C02A2F7008A2D19
/*
MaterialCapture.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96DF18201C02A2F7008A2D19
/* MaterialCapture
.swift */
;
};
96DF18211C02A2F7008A2D19
/*
CaptureSession.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96DF18201C02A2F7008A2D19
/* CaptureSession
.swift */
;
};
96DF18231C02B813008A2D19
/* CapturePreviewView.swift in Sources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
96DF18221C02B813008A2D19
/* CapturePreviewView.swift */
;
};
9A94D0FA1B895EA500F586A5
/* LICENSE in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
963832631B88E5BF0015F710
/* LICENSE */
;
};
9A94D0FB1B895EA500F586A5
/* Roboto-Regular.ttf in Resources */
=
{
isa
=
PBXBuildFile
;
fileRef
=
9AAC38591B8956E300FE6B2D
/* Roboto-Regular.ttf */
;
};
...
...
@@ -130,7 +130,7 @@
9699879B1BC5FE49006D678E
/* MaterialTextLayer.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialTextLayer.swift
;
sourceTree
=
"<group>"
;
};
96C4FABD1BC3168900E4FFC3
/* MaterialTransitionAnimation.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialTransitionAnimation.swift
;
sourceTree
=
"<group>"
;
};
96D26BFC1BC23649006478BD
/* ImageCardView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
ImageCardView.swift
;
sourceTree
=
"<group>"
;
};
96DF18201C02A2F7008A2D19
/*
MaterialCapture.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
MaterialCapture
.swift
;
sourceTree
=
"<group>"
;
};
96DF18201C02A2F7008A2D19
/*
CaptureSession.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CaptureSession
.swift
;
sourceTree
=
"<group>"
;
};
96DF18221C02B813008A2D19
/* CapturePreviewView.swift */
=
{
isa
=
PBXFileReference
;
fileEncoding
=
4
;
lastKnownFileType
=
sourcecode.swift
;
path
=
CapturePreviewView.swift
;
sourceTree
=
"<group>"
;
};
9AAC38551B8956C500FE6B2D
/* Roboto-Light.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Light.ttf"
;
sourceTree
=
"<group>"
;
};
9AAC38571B8956CF00FE6B2D
/* Roboto-Medium.ttf */
=
{
isa
=
PBXFileReference
;
lastKnownFileType
=
file
;
path
=
"Roboto-Medium.ttf"
;
sourceTree
=
"<group>"
;
};
...
...
@@ -335,7 +335,7 @@
96DF181F1C02A2CB008A2D19
/* Capture */
=
{
isa
=
PBXGroup
;
children
=
(
96DF18201C02A2F7008A2D19
/*
MaterialCapture
.swift */
,
96DF18201C02A2F7008A2D19
/*
CaptureSession
.swift */
,
96DF18221C02B813008A2D19
/* CapturePreviewView.swift */
,
);
name
=
Capture
;
...
...
@@ -518,7 +518,7 @@
65BDD14B1BB5DD02006F7F2B
/* MaterialFont.swift in Sources */
,
9699879C1BC5FE49006D678E
/* MaterialTextLayer.swift in Sources */
,
65BDD16A1BB7146B006F7F2B
/* MaterialBorder.swift in Sources */
,
96DF18211C02A2F7008A2D19
/*
MaterialCapture
.swift in Sources */
,
96DF18211C02A2F7008A2D19
/*
CaptureSession
.swift in Sources */
,
65BDD15B1BB7095E006F7F2B
/* MaterialRadius.swift in Sources */
,
65BDD1721BB8CD77006F7F2B
/* MaterialLabel.swift in Sources */
,
65BDD1491BB5DC98006F7F2B
/* MaterialColor.swift in Sources */
,
...
...
Source/CapturePreviewView.swift
View file @
47e5a079
...
...
@@ -30,7 +30,7 @@ public class CapturePreviewView : MaterialView {
/**
:name: capture
*/
public
private(set)
lazy
var
capture
:
MaterialCapture
=
MaterialCapture
()
public
private(set)
lazy
var
capture
Session
:
CaptureSession
=
CaptureSession
()
/**
:name: prepareView
...
...
@@ -58,6 +58,6 @@ public class CapturePreviewView : MaterialView {
// :name: prepareSession
//
private
func
prepareSession
()
{
(
layer
as!
AVCaptureVideoPreviewLayer
)
.
session
=
capture
.
session
(
layer
as!
AVCaptureVideoPreviewLayer
)
.
session
=
capture
Session
.
session
}
}
\ No newline at end of file
Source/CaptureSession.swift
0 → 100644
View file @
47e5a079
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
import
AVFoundation
@objc(CaptureSessionDelegate)
public
protocol
CaptureSessionDelegate
{
/**
:name: captureSessionFailedWithError
*/
optional
func
captureSessionFailedWithError
(
capture
:
CaptureSession
,
error
:
NSError
)
}
@objc(CaptureSession)
public
class
CaptureSession
:
NSObject
{
//
// :name: videoQueue
//
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: videoInput
//
private
var
videoInput
:
AVCaptureDeviceInput
?
//
// :name: audioInput
//
private
var
audioInput
:
AVCaptureDeviceInput
?
//
// :name: imageOutput
//
private
lazy
var
imageOutput
:
AVCaptureStillImageOutput
=
AVCaptureStillImageOutput
()
//
// :name: movieOutput
//
private
lazy
var
movieOutput
:
AVCaptureMovieFileOutput
=
AVCaptureMovieFileOutput
()
/**
:name: session
*/
public
private(set)
lazy
var
session
:
AVCaptureSession
=
AVCaptureSession
()
/**
:name: isRunning
*/
public
private(set)
lazy
var
isRunning
:
Bool
=
false
/**
:name: delegate
*/
public
weak
var
delegate
:
CaptureSessionDelegate
?
/**
:name: startSession
*/
public
func
startSesstion
()
{
if
!
isRunning
{
dispatch_async
(
videoQueue
)
{
self
.
session
.
startRunning
()
}
}
}
/**
:name: startSession
*/
public
func
stopSesstion
()
{
if
isRunning
{
dispatch_async
(
videoQueue
)
{
self
.
session
.
stopRunning
()
}
}
}
//
// :name: prepareSession
//
private
func
prepareSession
()
{
session
.
sessionPreset
=
AVCaptureSessionPresetHigh
prepareVideoInput
()
prepareAudioInput
()
prepareImageOutput
()
prepareMovieOutput
()
}
//
// :name: prepareVideoInput
//
private
func
prepareVideoInput
()
{
do
{
videoInput
=
try
AVCaptureDeviceInput
(
device
:
videoDevice
)
if
session
.
canAddInput
(
videoInput
)
{
session
.
addInput
(
videoInput
)
}
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionFailedWithError
?(
self
,
error
:
e
)
}
}
//
// :name: prepareAudioInput
//
private
func
prepareAudioInput
()
{
do
{
audioInput
=
try
AVCaptureDeviceInput
(
device
:
audioDevice
)
if
session
.
canAddInput
(
audioInput
)
{
session
.
addInput
(
audioInput
)
}
}
catch
let
e
as
NSError
{
delegate
?
.
captureSessionFailedWithError
?(
self
,
error
:
e
)
}
}
//
// :name: prepareImageOutput
//
private
func
prepareImageOutput
()
{
if
session
.
canAddOutput
(
imageOutput
)
{
imageOutput
.
outputSettings
=
[
AVVideoCodecKey
:
AVVideoCodecJPEG
]
session
.
addOutput
(
imageOutput
)
}
}
//
// :name: prepareMovieOutput
//
private
func
prepareMovieOutput
()
{
if
session
.
canAddOutput
(
movieOutput
)
{
session
.
addOutput
(
movieOutput
)
}
}
}
Source/MaterialCapture.swift
deleted
100644 → 0
View file @
dafbde3d
//
// Copyright (C) 2015 GraphKit, Inc. <http://graphkit.io> and other GraphKit contributors.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program located at the root of the software package
// in a file called LICENSE. If not, see <http://www.gnu.org/licenses/>.
//
import
UIKit
import
AVFoundation
@objc(MaterialCaptureDelegate)
public
protocol
MaterialCaptureDelegate
{
/**
:name: materialCaptureSessionFailedWithError
*/
optional
func
materialCaptureSessionFailedWithError
(
capture
:
MaterialCapture
,
error
:
NSError
)
}
@objc(MaterialCapture)
public
class
MaterialCapture
:
NSObject
{
/**
:name: cameraInput
*/
private
var
cameraInput
:
AVCaptureDeviceInput
?
/**
:name: imageOutput
*/
private
lazy
var
imageOutput
:
AVCaptureStillImageOutput
=
AVCaptureStillImageOutput
()
/**
:name: session
*/
public
private(set)
lazy
var
session
:
AVCaptureSession
=
AVCaptureSession
()
/**
:name: ccameraDevice
*/
public
private(set)
lazy
var
cameraDevice
:
AVCaptureDevice
=
AVCaptureDevice
.
defaultDeviceWithMediaType
(
AVMediaTypeVideo
)
/**
:name: delegate
*/
public
weak
var
delegate
:
MaterialCaptureDelegate
?
//
// :name: prepareSession
//
public
func
prepareSession
()
{
prepareCamera
()
}
//
// :name: prepareCamera
//
private
func
prepareCamera
()
{
do
{
cameraInput
=
try
AVCaptureDeviceInput
(
device
:
cameraDevice
)
if
session
.
canAddInput
(
cameraInput
)
{
session
.
addInput
(
cameraInput
)
}
if
session
.
canAddOutput
(
imageOutput
)
{
session
.
addOutput
(
imageOutput
)
}
session
.
startRunning
()
}
catch
let
e
as
NSError
{
delegate
?
.
materialCaptureSessionFailedWithError
?(
self
,
error
:
e
)
}
}
}
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