Revert "clang-format-3.7 --style=Google -i."

This reverts commit ad4beac464f6275bf78ce5b8d6958d9e7f232f36.
That commit wasn't as advertised; I had several other changes mixed in my
working copy. I'd also copied a working copy from one path to another, and
it turns out the cmake build subdir was still referring to the original, so
I hadn't realized this commit didn't even build. :(
This commit is contained in:
Scott Lamb 2016-01-31 21:53:43 -08:00
parent 1928569540
commit 708bbf5eb2
5 changed files with 22 additions and 58 deletions

View File

@ -46,6 +46,9 @@ set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb")
# Dependencies. # Dependencies.
# #
# https://cmake.org/cmake/help/v3.0/module/FindProtobuf.html
find_package(Protobuf REQUIRED)
# https://gflags.github.io/gflags/#cmake mentions a cmake module, but at # https://gflags.github.io/gflags/#cmake mentions a cmake module, but at
# least on Ubuntu 15.10, libgflags-dev does not include it. There's no # least on Ubuntu 15.10, libgflags-dev does not include it. There's no
# pkgconfig either. Do this by hand. # pkgconfig either. Do this by hand.

View File

@ -28,15 +28,16 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>. # along with this program. If not, see <http://www.gnu.org/licenses/>.
include_directories(${CMAKE_CURRENT_BINARY_DIR}) include_directories(${CMAKE_CURRENT_BINARY_DIR})
find_package(Threads REQUIRED) PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS config.protodevel)
set(MOONFIRE_DEPS set(MOONFIRE_DEPS
${CMAKE_THREAD_LIBS_INIT}
${FFMPEG_LIBRARIES} ${FFMPEG_LIBRARIES}
${LIBEVENT_LIBRARIES} ${LIBEVENT_LIBRARIES}
${GFLAGS_LIBRARIES} ${GFLAGS_LIBRARIES}
${GLOG_LIBRARIES} ${GLOG_LIBRARIES}
${OPENSSL_LIBRARIES} ${OPENSSL_LIBRARIES}
${PROFILER_LIBRARIES} ${PROFILER_LIBRARIES}
${PROTOBUF_LIBRARIES}
${RE2_LIBRARIES} ${RE2_LIBRARIES}
${SQLITE_LIBRARIES} ${SQLITE_LIBRARIES}
${UUID_LIBRARIES}) ${UUID_LIBRARIES})
@ -59,7 +60,7 @@ set(MOONFIRE_NVR_SRCS
uuid.cc uuid.cc
web.cc) web.cc)
add_library(moonfire-nvr-lib ${MOONFIRE_NVR_SRCS}) add_library(moonfire-nvr-lib ${MOONFIRE_NVR_SRCS} ${PROTO_SRCS} ${PROTO_HDRS})
target_link_libraries(moonfire-nvr-lib ${MOONFIRE_DEPS}) target_link_libraries(moonfire-nvr-lib ${MOONFIRE_DEPS})
add_executable(moonfire-nvr moonfire-nvr-main.cc) add_executable(moonfire-nvr moonfire-nvr-main.cc)

View File

@ -59,11 +59,6 @@ bool MoonfireDatabase::Init(Database *db, std::string *error_message) {
camera.uuid, camera.uuid,
camera.short_name, camera.short_name,
camera.description, camera.description,
camera.host,
camera.username,
camera.password,
camera.main_rtsp_path,
camera.sub_rtsp_path,
camera.retain_bytes, camera.retain_bytes,
min(recording.start_time_90k), min(recording.start_time_90k),
max(recording.start_time_90k + recording.duration_90k), max(recording.start_time_90k + recording.duration_90k),
@ -85,26 +80,21 @@ bool MoonfireDatabase::Init(Database *db, std::string *error_message) {
Uuid uuid; Uuid uuid;
if (!uuid.ParseBinary(list_cameras_run.ColumnBlob(1))) { if (!uuid.ParseBinary(list_cameras_run.ColumnBlob(1))) {
*error_message = *error_message =
StrCat("bad uuid ", ToHex(list_cameras_run.ColumnBlob(1)), StrCat("bad uuid ", ToHex(list_cameras_run.ColumnBlob(2)),
" for camera id ", data.id); " for camera id ", data.id);
return false; return false;
} }
data.short_name = list_cameras_run.ColumnText(2).as_string(); data.short_name = list_cameras_run.ColumnText(2).as_string();
data.description = list_cameras_run.ColumnText(3).as_string(); data.description = list_cameras_run.ColumnText(3).as_string();
data.host = list_cameras_run.ColumnText(4).as_string(); data.retain_bytes = list_cameras_run.ColumnInt64(4);
data.username = list_cameras_run.ColumnText(5).as_string(); data.min_start_time_90k = list_cameras_run.ColumnType(5) == SQLITE_NULL
data.password = list_cameras_run.ColumnText(6).as_string();
data.main_rtsp_path = list_cameras_run.ColumnText(7).as_string();
data.sub_rtsp_path = list_cameras_run.ColumnText(8).as_string();
data.retain_bytes = list_cameras_run.ColumnInt64(9);
data.min_start_time_90k = list_cameras_run.ColumnType(10) == SQLITE_NULL
? -1 ? -1
: list_cameras_run.ColumnInt64(10); : list_cameras_run.ColumnInt64(5);
data.max_end_time_90k = list_cameras_run.ColumnType(11) == SQLITE_NULL data.max_end_time_90k = list_cameras_run.ColumnType(6) == SQLITE_NULL
? -1 ? -1
: list_cameras_run.ColumnInt64(11); : list_cameras_run.ColumnInt64(6);
data.total_duration_90k = list_cameras_run.ColumnInt64(12); data.total_duration_90k = list_cameras_run.ColumnInt64(7);
data.total_sample_file_bytes = list_cameras_run.ColumnInt64(13); data.total_sample_file_bytes = list_cameras_run.ColumnInt64(8);
auto ret = cameras_by_uuid_.insert(std::make_pair(uuid, data)); auto ret = cameras_by_uuid_.insert(std::make_pair(uuid, data));
if (!ret.second) { if (!ret.second) {
@ -317,15 +307,9 @@ void MoonfireDatabase::ListCameras(
DatabaseContext ctx(db_); DatabaseContext ctx(db_);
ListCamerasRow row; ListCamerasRow row;
for (const auto &entry : cameras_by_uuid_) { for (const auto &entry : cameras_by_uuid_) {
row.id = entry.second.id;
row.uuid = entry.first; row.uuid = entry.first;
row.short_name = entry.second.short_name; row.short_name = entry.second.short_name;
row.description = entry.second.description; row.description = entry.second.description;
row.host = entry.second.host;
row.username = entry.second.username;
row.password = entry.second.password;
row.main_rtsp_path = entry.second.main_rtsp_path;
row.sub_rtsp_path = entry.second.sub_rtsp_path;
row.retain_bytes = entry.second.retain_bytes; row.retain_bytes = entry.second.retain_bytes;
row.min_start_time_90k = entry.second.min_start_time_90k; row.min_start_time_90k = entry.second.min_start_time_90k;
row.max_end_time_90k = entry.second.max_end_time_90k; row.max_end_time_90k = entry.second.max_end_time_90k;
@ -563,10 +547,11 @@ std::vector<Uuid> MoonfireDatabase::ReserveSampleFiles(
if (n == 0) { if (n == 0) {
return std::vector<Uuid>(); return std::vector<Uuid>();
} }
auto *gen = GetRealUuidGenerator();
std::vector<Uuid> uuids; std::vector<Uuid> uuids;
uuids.reserve(n); uuids.reserve(n);
for (int i = 0; i < n; ++i) { for (int i = 0; i < n; ++i) {
uuids.push_back(GetRealUuidGenerator->Generate()); uuids.push_back(gen->Generate());
} }
DatabaseContext ctx(db_); DatabaseContext ctx(db_);
if (!ctx.BeginTransaction(error_message)) { if (!ctx.BeginTransaction(error_message)) {
@ -616,10 +601,7 @@ bool MoonfireDatabase::InsertVideoSampleEntry(VideoSampleEntry *entry,
insert_run.BindInt64(":height", entry->height); insert_run.BindInt64(":height", entry->height);
insert_run.BindBlob(":data", entry->data); insert_run.BindBlob(":data", entry->data);
if (insert_run.Step() != SQLITE_DONE) { if (insert_run.Step() != SQLITE_DONE) {
*error_message = *error_message = insert_run.error_message();
StrCat("insert video sample entry: ", insert_run.error_message(),
": sha1=", ToHex(entry->sha1), ", dimensions=", entry->width,
"x", entry->height, ", data=", ToHex(entry->data));
return false; return false;
} }
entry->id = ctx.last_insert_rowid(); entry->id = ctx.last_insert_rowid();
@ -678,19 +660,7 @@ bool MoonfireDatabase::InsertRecording(Recording *recording,
insert_run.BindBlob(":sample_file_sha1", recording->sample_file_sha1); insert_run.BindBlob(":sample_file_sha1", recording->sample_file_sha1);
insert_run.BindBlob(":video_index", recording->video_index); insert_run.BindBlob(":video_index", recording->video_index);
if (insert_run.Step() != SQLITE_DONE) { if (insert_run.Step() != SQLITE_DONE) {
LOG(ERROR) << "insert_run failed: " << insert_run.error_message() LOG(ERROR) << "insert_run failed: " << insert_run.error_message();
<< ", camera_id=" << recording->camera_id
<< ", sample_file_bytes=" << recording->sample_file_bytes
<< ", start_time_90k=" << recording->start_time_90k
<< ", duration_90k="
<< recording->end_time_90k - recording->start_time_90k
<< ", video_samples=" << recording->video_samples
<< ", video_sync_samples=" << recording->video_sync_samples
<< ", video_sample_entry_id=" << recording->video_sample_entry_id
<< ", sample_file_uuid="
<< recording->sample_file_uuid.UnparseText()
<< ", sample_file_sha1=" << ToHex(recording->sample_file_sha1)
<< ", video_index length " << recording->video_index.size();
*error_message = insert_run.error_message(); *error_message = insert_run.error_message();
ctx.RollbackTransaction(); ctx.RollbackTransaction();
return false; return false;

View File

@ -75,15 +75,9 @@ namespace moonfire_nvr {
// For use with MoonfireDatabase::ListCameras. // For use with MoonfireDatabase::ListCameras.
struct ListCamerasRow { struct ListCamerasRow {
int64_t id = -1;
Uuid uuid; Uuid uuid;
std::string short_name; std::string short_name;
std::string description; std::string description;
std::string host;
std::string username;
std::string password;
std::string main_rtsp_path;
std::string sub_rtsp_path;
int64_t retain_bytes = -1; int64_t retain_bytes = -1;
// Aggregates summarizing completed recordings. // Aggregates summarizing completed recordings.
@ -215,11 +209,6 @@ class MoonfireDatabase {
int64_t id = -1; int64_t id = -1;
std::string short_name; std::string short_name;
std::string description; std::string description;
std::string host;
std::string username;
std::string password;
std::string main_rtsp_path;
std::string sub_rtsp_path;
int64_t retain_bytes = -1; int64_t retain_bytes = -1;
// Aggregates of all recordings associated with the camera. // Aggregates of all recordings associated with the camera.
@ -237,7 +226,7 @@ class MoonfireDatabase {
int64_t *max_end_time_90k, int64_t *max_end_time_90k,
std::string *error_message); std::string *error_message);
Environment *env_ = nullptr; Database *db_ = nullptr;
Statement list_camera_recordings_stmt_; Statement list_camera_recordings_stmt_;
Statement build_mp4_stmt_; Statement build_mp4_stmt_;
Statement insert_reservation_stmt_; Statement insert_reservation_stmt_;

View File

@ -136,7 +136,8 @@ void WebInterface::HandleCameraDetail(evhttp_request *req, void *arg) {
// Rather than listing each 60-second recording, generate a HTML row for // Rather than listing each 60-second recording, generate a HTML row for
// aggregated .mp4 files of up to kForceSplitDuration90k each, provided // aggregated .mp4 files of up to kForceSplitDuration90k each, provided
// there is no gap or change in video parameters between recordings. // there is no gap or change in video parameters between recordings.
static const int64_t kForceSplitDuration90k = 60 * 60 * kTimeUnitsPerSecond; static const int64_t kForceSplitDuration90k =
60 * 60 * kTimeUnitsPerSecond;
ListCameraRecordingsRow aggregated; ListCameraRecordingsRow aggregated;
auto maybe_finish_html_row = [&]() { auto maybe_finish_html_row = [&]() {
if (aggregated.start_time_90k == -1) { if (aggregated.start_time_90k == -1) {