-
Notifications
You must be signed in to change notification settings - Fork 774
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement async callback for Android mediacodec #4105
base: master
Are you sure you want to change the base?
Conversation
AtomicQueue() {} | ||
}; | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Headers in
include
dir are meant to be public API, so by convention it should use a specific prefix such aspj
orpjmedia
. - If this is public API, IMO, the interface better uses C (as used by the rest), e.g:
pj_atomic_queue
, and perhaps part of PJLIB instead of PJMEDIA, note that the implementation can still use C++.
pj_atomic_queue() {} | ||
}; | ||
|
||
#endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely still C++ (with C naming style :)
Please check ioqueue_symbian.cpp
which use ioqueue.h
.
pjlib/src/pj/atomic_queue.cpp
Outdated
|
||
#if defined(PJ_ANDROID) && PJ_ANDROID != 0 | ||
|
||
//#include <android/log.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For tracing purpose, perhaps it can use the usual approach, e.g: using PJLIB log (instead of Android), tracing is by default disabled.
pjlib/include/pj/atomic_queue.h
Outdated
/* Atomic queue (ring buffer) for single consumer & single producer. | ||
* | ||
* Producer invokes 'pj_atomic_queue_put(item)' to put an item to the back of | ||
* the queue. | ||
* Consumer invokes 'pj_atomic_queue_get(item)' to get an item from the head of | ||
* the queue. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not seem to be part of the docs?
Note that the "single consumer & single producer" condition needs to be explicitly specified in the docs.
pjlib/src/pj/atomic_queue.cpp
Outdated
PJ_DEF(pj_status_t) pj_atomic_queue_put(pj_atomic_queue_t *atomic_queue, | ||
void *item) | ||
{ | ||
PJ_ASSERT_RETURN(atomic_queue && atomic_queue->aQ, PJ_EINVAL); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check item
too?
Also below.
const char* name, | ||
pj_atomic_queue_t **atomic_queue) | ||
{ | ||
pj_atomic_queue_t *aqueue; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add pre-verification/PJ_ASSERT_RETURN()
?
Also below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add in the PR description as to why this PR is needed, e.g. is there any performance issue with the current polling approach?
If yes, does using atomic queue manage to improve performance/reduce video lags (especially when compared to using other codec backend such as OpenH264)?
pjlib/include/pj/atomic_queue.h
Outdated
PJ_DECL(pj_status_t) pj_atomic_queue_destroy(pj_atomic_queue_t *atomic_queue); | ||
|
||
/** | ||
* Put a item to the back of the queue. If the queue is almost full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an item.
What does "almost" full mean?
} | ||
|
||
/** | ||
* Get a item from the head of the queue |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an item.
Also below.
pjlib/src/pj/atomic_queue.cpp
Outdated
/* Surpress warning when debugging log is disabled */ | ||
PJ_UNUSED_ARG(name_); | ||
|
||
// PJ_LOG(5, (name_, "Created AtomicQueue: maxItemCnt=%d itemSize=%d", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than comment it, better disable it as @nanangizz suggested, such as using macro TRACE, so we can easily enable it when logging is needed.
Unfortunately, the lag/delay issue still noticeable.
|
This is the current pattern for encoding/decoding using Android media codec:
Issues related to this pattern/when using polling:
This patch will use an async callback to the implementation.
Notes:
oboe_dev.cpp