/
camera_list.cpp
51 lines (44 loc) · 981 Bytes
/
camera_list.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include "base.h"
#include "dslrException.h"
#include "camera_list.h"
#include "camera.h"
namespace dslr {
CameraList::CameraList()
: list_(nullptr)
{
EdsError err = EdsGetCameraList(&list_);
if (EDS_ERR_OK != err) {
DEBUGSTREAM << DescribeError(err) << std::endl;
throw Exception(err);
}
}
CameraList::~CameraList()
{
if (list_) {
EdsRelease(list_);
list_ = nullptr;
}
}
int CameraList::Count() const
{
EdsUInt32 count = -1;
EdsError err = EdsGetChildCount(list_, &count);
if (err != EDS_ERR_OK) {
DEBUGSTREAM << DescribeError(err) << std::endl;
throw Exception(err);
}
return count;
}
Camera CameraList::get(const int index)
{
EdsCameraRef camera = nullptr;
EdsError err = EdsGetChildAtIndex(list_, 0, &camera);
if (EDS_ERR_OK != err) {
DEBUGSTREAM << DescribeError(err) << std::endl;
throw Exception(err);
}
Camera retval = Camera(camera);
retval.Initialize();
return retval;
}
} // namespace dslr