2018-09-25 15:17:14 -04:00
|
|
|
/*
|
2024-01-02 14:56:41 -05:00
|
|
|
* Copyright (C) 2004-2024 Savoir-faire Linux Inc.
|
2018-09-25 15:17:14 -04:00
|
|
|
*
|
2024-11-11 22:42:10 -05:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2018-09-25 15:17:14 -04:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2024-11-11 22:42:10 -05:00
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
2018-09-25 15:17:14 -04:00
|
|
|
* (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
|
2024-11-11 22:42:10 -05:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2018-09-25 15:17:14 -04:00
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2024-11-11 22:42:10 -05:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2018-09-25 15:17:14 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <cppunit/TestAssert.h>
|
|
|
|
#include <cppunit/TestFixture.h>
|
|
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include <libavutil/frame.h>
|
|
|
|
#include <libavutil/pixfmt.h>
|
|
|
|
}
|
|
|
|
|
daemon: Rename dring occurrences in code and file names to jamid.
Automated using the following commands:
$ mv src/{dring,jami}
$ git grep -l src/dring | xargs sed -i 's,src/dring,src/jami,g'
$ git grep -l '#include "dring/' | \
xargs sed -i 's,#include "dring/,#include "jami/,g'
$ git grep -l 'dring.h' | xargs sed -i 's,dring.h,jami.h,g'
And finally,
$ git grep -l 'dring' | xargs sed -i 's,dring,jami,g'
$ files=$(find -name '*dring*' | sort)
$ for f in $files; do mkdir -p "$(dirname "$f")"; \
mv "$f" "$(echo $f | sed 's/dring/jami/g')"; done
To resolve a bad renaming favorably:
$ git grep -l -i AlsaCarjami | \
xargs sed -i -E 's/([Aa])lsaCarjami/\1lsaCardRingtone/g'
The above renaming command is not perfect, so some hand-tuning was
required to complete it.
* src/manager.cpp (Manager::ManagerPimpl::retrieveConfigPath):
Preserve the dring.yml configuration file name, until we add something
to migrate (rename) it to jami.yml.
* man/dring.pod: Delete.
* bin/dbus/jamid.pod: Move to ...
* man/jamid.pod: here.
* bin/dbus/meson.build (jamid_targets): Normalize man section to the
pre-existing 1 and adjust accordingly.
* src/jami/def.h (dring_EXPORTS): Rename to ...
(jami_EXPORTS): ... this.
change-Id: I9828be6da9c711ab2f22c4d1b9539fea89d7b6fb
2021-06-15 11:03:11 -04:00
|
|
|
#include "jami.h"
|
2018-09-25 15:17:14 -04:00
|
|
|
#include "videomanager_interface.h"
|
2023-09-25 13:37:16 -04:00
|
|
|
#include "media/audio/audio_format.h"
|
2018-09-25 15:17:14 -04:00
|
|
|
|
|
|
|
#include "../../test_runner.h"
|
|
|
|
|
2019-04-02 17:10:48 -04:00
|
|
|
namespace jami { namespace test {
|
2018-09-25 15:17:14 -04:00
|
|
|
|
|
|
|
class MediaFrameTest : public CppUnit::TestFixture {
|
|
|
|
public:
|
|
|
|
static std::string name() { return "media_frame"; }
|
|
|
|
|
|
|
|
void setUp();
|
|
|
|
void tearDown();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void testCopy();
|
2018-11-28 13:44:13 -05:00
|
|
|
void testMix();
|
2018-09-25 15:17:14 -04:00
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE(MediaFrameTest);
|
|
|
|
CPPUNIT_TEST(testCopy);
|
2018-11-28 13:44:13 -05:00
|
|
|
CPPUNIT_TEST(testMix);
|
2018-09-25 15:17:14 -04:00
|
|
|
CPPUNIT_TEST_SUITE_END();
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_NAMED_REGISTRATION(MediaFrameTest, MediaFrameTest::name());
|
|
|
|
|
|
|
|
void
|
|
|
|
MediaFrameTest::setUp()
|
|
|
|
{
|
2022-10-27 16:00:41 -04:00
|
|
|
libjami::init(libjami::InitFlag(libjami::LIBJAMI_FLAG_DEBUG | libjami::LIBJAMI_FLAG_CONSOLE_LOG));
|
2018-09-25 15:17:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MediaFrameTest::tearDown()
|
|
|
|
{
|
2022-10-27 16:00:41 -04:00
|
|
|
libjami::fini();
|
2018-09-25 15:17:14 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
MediaFrameTest::testCopy()
|
|
|
|
{
|
|
|
|
// test allocation
|
2022-10-27 16:00:41 -04:00
|
|
|
libjami::VideoFrame v1;
|
2018-09-25 15:17:14 -04:00
|
|
|
v1.reserve(AV_PIX_FMT_YUV420P, 100, 100);
|
|
|
|
v1.pointer()->data[0][0] = 42;
|
|
|
|
CPPUNIT_ASSERT(v1.pointer());
|
|
|
|
|
|
|
|
// test frame referencing (different pointers, but same data)
|
2022-10-27 16:00:41 -04:00
|
|
|
libjami::VideoFrame v2;
|
2018-09-25 15:17:14 -04:00
|
|
|
v2.copyFrom(v1);
|
|
|
|
CPPUNIT_ASSERT(v1.format() == v2.format());
|
|
|
|
CPPUNIT_ASSERT(v1.width() == v2.width());
|
|
|
|
CPPUNIT_ASSERT(v1.height() == v2.height());
|
|
|
|
CPPUNIT_ASSERT(v1.pointer() != v2.pointer());
|
|
|
|
CPPUNIT_ASSERT(v1.pointer()->data[0][0] == 42);
|
|
|
|
CPPUNIT_ASSERT(v2.pointer()->data[0][0] == 42);
|
|
|
|
}
|
|
|
|
|
2018-11-28 13:44:13 -05:00
|
|
|
void
|
|
|
|
MediaFrameTest::testMix()
|
|
|
|
{
|
|
|
|
const AudioFormat& format = AudioFormat::STEREO();
|
|
|
|
const int nbSamples = format.sample_rate / 50;
|
2022-10-27 16:00:41 -04:00
|
|
|
auto a1 = std::make_unique<libjami::AudioFrame>(format, nbSamples);
|
2023-09-25 13:37:16 -04:00
|
|
|
auto d1 = reinterpret_cast<int16_t*>(a1->pointer()->extended_data[0]);
|
2018-11-28 13:44:13 -05:00
|
|
|
d1[0] = 0;
|
|
|
|
d1[1] = 1;
|
|
|
|
d1[2] = 3;
|
|
|
|
d1[3] = -2;
|
|
|
|
d1[4] = 5;
|
2023-09-25 13:37:16 -04:00
|
|
|
d1[5] = std::numeric_limits<int16_t>::min();
|
|
|
|
d1[6] = std::numeric_limits<int16_t>::max();
|
2022-10-27 16:00:41 -04:00
|
|
|
auto a2 = std::make_unique<libjami::AudioFrame>(format, nbSamples);
|
2023-09-25 13:37:16 -04:00
|
|
|
auto d2 = reinterpret_cast<int16_t*>(a2->pointer()->extended_data[0]);
|
2018-11-28 13:44:13 -05:00
|
|
|
d2[0] = 0;
|
|
|
|
d2[1] = 3;
|
|
|
|
d2[2] = -1;
|
|
|
|
d2[3] = 3;
|
|
|
|
d2[4] = -6;
|
|
|
|
d2[5] = -101;
|
|
|
|
d2[6] = 101;
|
|
|
|
a2->mix(*a1);
|
|
|
|
CPPUNIT_ASSERT(d2[0] == 0);
|
|
|
|
CPPUNIT_ASSERT(d2[1] == 4);
|
|
|
|
CPPUNIT_ASSERT(d2[2] == 2);
|
|
|
|
CPPUNIT_ASSERT(d2[3] == 1);
|
|
|
|
CPPUNIT_ASSERT(d2[4] == -1);
|
2023-09-25 13:37:16 -04:00
|
|
|
CPPUNIT_ASSERT(d2[5] == std::numeric_limits<int16_t>::min());
|
|
|
|
CPPUNIT_ASSERT(d2[6] == std::numeric_limits<int16_t>::max());
|
2018-11-28 13:44:13 -05:00
|
|
|
}
|
|
|
|
|
2019-04-02 17:10:48 -04:00
|
|
|
}} // namespace jami::test
|
2018-09-25 15:17:14 -04:00
|
|
|
|
2019-04-02 17:10:48 -04:00
|
|
|
RING_TEST_RUNNER(jami::test::MediaFrameTest::name());
|