Skip to content

Commit 4817269

Browse files
committed
test: finalize tests
1 parent 83176ee commit 4817269

File tree

3 files changed

+31
-53
lines changed

3 files changed

+31
-53
lines changed

.github/actions/deps/action.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,16 @@ runs:
9191
if: inputs.for-test == 'true' && steps.cache-gst.outputs.cache-hit != 'true'
9292
uses: actions-rust-lang/setup-rust-toolchain@11df97af8e8102fd60b60a77dfbf58d40cd843b8
9393

94+
- name: Install cargo-c
95+
if: inputs.for-test == 'true' && steps.cache-gst.outputs.cache-hit != 'true'
96+
shell: bash
97+
run: |
98+
if [[ ${{ runner.os }} == 'macOS' ]]; then
99+
brew install cargo-c
100+
else
101+
cargo install cargo-c
102+
fi
103+
94104
- name: Clone gst-plugins-rs
95105
if: inputs.for-test == 'true' && steps.cache-gst.outputs.cache-hit != 'true'
96106
shell: bash
@@ -109,7 +119,6 @@ runs:
109119
shell: bash
110120
working-directory: ${{ runner.temp }}/gst-plugins-rs
111121
run: |
112-
cargo install cargo-c
113122
cargo cbuild -p gst-plugin-fmp4
114123
cargo cinstall -p gst-plugin-fmp4 --destdir bin
115124

tests/src/common.hpp

+9-45
Original file line numberDiff line numberDiff line change
@@ -7,28 +7,8 @@
77
class GstAppSink
88
{
99
private:
10-
std::mutex buffer_queue_mutex;
11-
std::condition_variable buffer_queue_cv;
12-
GQueue* buffer_queue;
1310
GstElement* appsink;
1411

15-
protected:
16-
static GstFlowReturn NewSample(GstElement* sink, GstAppSink* self)
17-
{
18-
GstSample* sample;
19-
g_signal_emit_by_name(sink, "pull-sample", &sample);
20-
if (sample == NULL)
21-
return GST_FLOW_ERROR;
22-
23-
// Push the sample into the buffer queue
24-
GstBufferList* buffer = gst_sample_get_buffer_list(sample);
25-
gst_buffer_list_ref(buffer);
26-
g_queue_push_tail(self->buffer_queue, buffer);
27-
gst_sample_unref(sample);
28-
self->buffer_queue_cv.notify_one();
29-
return GST_FLOW_OK;
30-
}
31-
3212
public:
3313
GstAppSink(GstElement* test_element, GstElement* tee, GstElement* pipeline)
3414
{
@@ -43,8 +23,6 @@ class GstAppSink
4323
// Set the appsink properties
4424
g_object_set(
4525
appsink, "emit-signals", TRUE, "sync", FALSE, "buffer-list", TRUE, NULL);
46-
g_signal_connect(appsink, "new-sample", G_CALLBACK(NewSample), this);
47-
buffer_queue = g_queue_new();
4826

4927
// Add the appsink to the test element
5028
gst_bin_add_many(GST_BIN(pipeline), queue, test_element, appsink, NULL);
@@ -60,33 +38,19 @@ class GstAppSink
6038

6139
GstBufferList* PopBuffer()
6240
{
63-
// Wait until we have at least one buffer in the queue
64-
std::unique_lock<std::mutex> lock(buffer_queue_mutex);
65-
buffer_queue_cv.wait(lock, [&]() {
66-
gboolean eos = false;
67-
g_object_get(G_OBJECT(this->appsink), "eos", &eos, NULL);
68-
if (eos)
69-
return true;
70-
return !g_queue_is_empty(this->buffer_queue);
71-
});
72-
73-
return (GstBufferList*)g_queue_pop_head(buffer_queue);
74-
}
41+
GstSample* sample;
42+
g_signal_emit_by_name(appsink, "pull-sample", &sample);
43+
if (sample == NULL)
44+
return NULL;
7545

76-
~GstAppSink()
77-
{
78-
// Flush the buffer queue
79-
while (!g_queue_is_empty(buffer_queue)) {
80-
GstBufferList* buffer = (GstBufferList*)g_queue_pop_head(buffer_queue);
81-
gst_buffer_list_unref(buffer);
82-
}
46+
GstBufferList* buffer = gst_sample_get_buffer_list(sample);
47+
gst_buffer_list_ref(buffer);
48+
gst_sample_unref(sample);
8349

84-
// Free resources
85-
gst_object_unref(appsink);
86-
g_queue_free(buffer_queue);
50+
return buffer;
8751
}
8852

89-
int GetBufferCount() { return g_queue_get_length(buffer_queue); }
53+
~GstAppSink() { gst_object_unref(appsink); }
9054
};
9155

9256
class GstTestFixture : public ::testing::Test

tests/src/mp4mx_cross.cc

+12-7
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extract_box_fourccs(GstBuffer* buffer,
3434
}
3535

3636
void
37-
CheckSegmentInit(GstBuffer* buffer)
37+
IsSegmentInit(GstBuffer* buffer)
3838
{
3939
// It must only have the following flags
4040
EXPECT_TRUE(GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_HEADER));
@@ -159,7 +159,7 @@ TEST_F(GstTestFixture, StructureTest)
159159

160160
// Check buffer #0
161161
GET_NEXT_BUFFER();
162-
CheckSegmentInit(buf);
162+
IsSegmentInit(buf);
163163

164164
if (is_cmaf)
165165
first_cmaf_buffer = false;
@@ -227,13 +227,18 @@ TEST_F(GstTestFixture, TimingTest)
227227
GstBuffer* cmaf_buf = gst_buffer_list_get(cmaf_buffer, idx);
228228
GstBuffer* gpacmp4mx_buf = gst_buffer_list_get(gpacmp4mx_buffer, idx);
229229

230-
// Check the CTS and DTS
230+
// Check only the PTS
231231
EXPECT_EQ(GST_BUFFER_PTS(cmaf_buf), GST_BUFFER_PTS(gpacmp4mx_buf));
232-
EXPECT_EQ(GST_BUFFER_DTS(cmaf_buf), GST_BUFFER_DTS(gpacmp4mx_buf));
233232

234-
// Check the duration
235-
EXPECT_EQ(GST_BUFFER_DURATION(cmaf_buf),
236-
GST_BUFFER_DURATION(gpacmp4mx_buf));
233+
// The duration differs because, compared to cmafmux, we are
234+
// outputting complete segments rather than dividing the mdat across
235+
// individual buffers by samples.
236+
if (!GST_BUFFER_FLAG_IS_SET(cmaf_buf, GST_BUFFER_FLAG_DELTA_UNIT)) {
237+
EXPECT_EQ(GST_BUFFER_DURATION(cmaf_buf),
238+
GST_BUFFER_DURATION(gpacmp4mx_buf));
239+
}
240+
241+
// For the same reason, the DTS is also not the same.
237242
}
238243

239244
#undef GET_NEXT_BUFFER

0 commit comments

Comments
 (0)