From 07ab76f377abd3a5f8df1db3299269e10e5290e2 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Wed, 13 Jun 2018 19:35:06 +0200 Subject: [PATCH] timestamp_calculator_c: `add_timestamp` overload with `boost::optional` --- src/merge/timestamp_calculator.cpp | 9 ++++++++- src/merge/timestamp_calculator.h | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/merge/timestamp_calculator.cpp b/src/merge/timestamp_calculator.cpp index 37776d02e..6b0d1fefd 100644 --- a/src/merge/timestamp_calculator.cpp +++ b/src/merge/timestamp_calculator.cpp @@ -45,10 +45,17 @@ timestamp_calculator_c::add_timestamp(timestamp_c const ×tamp, void timestamp_calculator_c::add_timestamp(int64_t timestamp, boost::optional stream_position) { - if (-1 != timestamp) + if (0 <= timestamp) add_timestamp(timestamp_c::ns(timestamp), stream_position); } +void +timestamp_calculator_c::add_timestamp(boost::optional const ×tamp, + boost::optional stream_position) { + if (timestamp && (0 <= *timestamp)) + add_timestamp(timestamp_c::ns(*timestamp), stream_position); +} + void timestamp_calculator_c::add_timestamp(packet_cptr const &packet, boost::optional stream_position) { diff --git a/src/merge/timestamp_calculator.h b/src/merge/timestamp_calculator.h index 6e06705fe..06e47410c 100644 --- a/src/merge/timestamp_calculator.h +++ b/src/merge/timestamp_calculator.h @@ -34,6 +34,7 @@ private: public: timestamp_calculator_c(int64_t samples_per_second); + void add_timestamp(boost::optional const ×tamp, boost::optional stream_position = boost::none); void add_timestamp(timestamp_c const ×tamp, boost::optional stream_position = boost::none); void add_timestamp(int64_t timestamp, boost::optional stream_position = boost::none); void add_timestamp(packet_cptr const &packet, boost::optional stream_position = boost::none);