1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

Fix #301, User must config the codec in right way for HLS. 3.0.18

This commit is contained in:
winlin 2017-02-12 20:55:35 +08:00
parent d612a21bad
commit 2a4f57a587
6 changed files with 6 additions and 60 deletions

View file

@ -186,6 +186,7 @@ Please select your language:
### V3 changes ### V3 changes
* v3.0, 2017-02-12, Fix [#301][bug #301], User must config the codec in right way for HLS. 3.0.18
* v3.0, 2017-02-07, fix [#738][bug #738] support DVR general mp4. 3.0.17 * v3.0, 2017-02-07, fix [#738][bug #738] support DVR general mp4. 3.0.17
* v3.0, 2017-01-19, for [#742][bug #742] refine source, meta and origin hub. 3.0.16 * v3.0, 2017-01-19, for [#742][bug #742] refine source, meta and origin hub. 3.0.16
* v3.0, 2017-01-17, for [#742][bug #742] refine source, timeout, live cycle. 3.0.15 * v3.0, 2017-01-17, for [#742][bug #742] refine source, timeout, live cycle. 3.0.15
@ -1219,8 +1220,6 @@ Winlin
[bug #310]: https://github.com/ossrs/srs/issues/310 [bug #310]: https://github.com/ossrs/srs/issues/310
[bug #136]: https://github.com/ossrs/srs/issues/136 [bug #136]: https://github.com/ossrs/srs/issues/136
[bug #250]: https://github.com/ossrs/srs/issues/250 [bug #250]: https://github.com/ossrs/srs/issues/250
[bug #301]: https://github.com/ossrs/srs/issues/301
[bug #301]: https://github.com/ossrs/srs/issues/301
[bug #268]: https://github.com/ossrs/srs/issues/268 [bug #268]: https://github.com/ossrs/srs/issues/268
[bug #151]: https://github.com/ossrs/srs/issues/151 [bug #151]: https://github.com/ossrs/srs/issues/151
[bug #151]: https://github.com/ossrs/srs/issues/151 [bug #151]: https://github.com/ossrs/srs/issues/151

View file

@ -223,7 +223,6 @@ SrsHlsMuxer::SrsHlsMuxer()
max_td = 0; max_td = 0;
_sequence_no = 0; _sequence_no = 0;
current = NULL; current = NULL;
acodec = SrsAudioCodecIdReserved1;
async = new SrsAsyncCallWorker(); async = new SrsAsyncCallWorker();
context = new SrsTsContext(); context = new SrsTsContext();
} }
@ -478,14 +477,7 @@ int SrsHlsMuxer::segment_open(int64_t segment_start_dts)
srs_error("open hls muxer failed. ret=%d", ret); srs_error("open hls muxer failed. ret=%d", ret);
return ret; return ret;
} }
srs_info("open HLS muxer success. path=%s, tmp=%s", srs_info("open HLS muxer success. path=%s, tmp=%s", current->full_path.c_str(), tmp_file.c_str());
current->full_path.c_str(), tmp_file.c_str());
// set the segment muxer audio codec.
// TODO: FIXME: refine code, use event instead.
if (acodec != SrsAudioCodecIdReserved1) {
current->muxer->update_acodec(acodec);
}
return ret; return ret;
} }
@ -543,14 +535,6 @@ bool SrsHlsMuxer::is_segment_absolutely_overflow()
return current->duration >= hls_aof_ratio * hls_fragment + deviation; return current->duration >= hls_aof_ratio * hls_fragment + deviation;
} }
int SrsHlsMuxer::update_acodec(SrsAudioCodecId ac)
{
srs_assert(current);
srs_assert(current->muxer);
acodec = ac;
return current->muxer->update_acodec(ac);
}
bool SrsHlsMuxer::pure_audio() bool SrsHlsMuxer::pure_audio()
{ {
return current && current->muxer && current->muxer->video_codec() == SrsVideoCodecIdDisabled; return current && current->muxer && current->muxer->video_codec() == SrsVideoCodecIdDisabled;
@ -863,11 +847,6 @@ void SrsHlsController::dispose()
muxer->dispose(); muxer->dispose();
} }
int SrsHlsController::update_acodec(SrsAudioCodecId ac)
{
return muxer->update_acodec(ac);
}
int SrsHlsController::sequence_no() int SrsHlsController::sequence_no()
{ {
return muxer->sequence_no(); return muxer->sequence_no();
@ -1221,12 +1200,6 @@ int SrsHls::on_audio(SrsSharedPtrMessage* shared_audio, SrsFormat* format)
return ret; return ret;
} }
// when codec changed, write new header.
if ((ret = controller->update_acodec(acodec)) != ERROR_SUCCESS) {
srs_error("http: ts audio write header failed. ret=%d", ret);
return ret;
}
// ignore sequence header // ignore sequence header
srs_assert(format->audio); srs_assert(format->audio);
if (acodec == SrsAudioCodecIdAAC && format->audio->aac_packet_type == SrsAudioAacFrameTraitSequenceHeader) { if (acodec == SrsAudioCodecIdAAC && format->audio->aac_packet_type == SrsAudioAacFrameTraitSequenceHeader) {

View file

@ -174,12 +174,6 @@ private:
* current writing segment. * current writing segment.
*/ */
SrsHlsSegment* current; SrsHlsSegment* current;
/**
* the current audio codec, when open new muxer,
* set the muxer audio codec.
* @see https://github.com/ossrs/srs/issues/301
*/
SrsAudioCodecId acodec;
/** /**
* the ts context, to keep cc continous between ts. * the ts context, to keep cc continous between ts.
* @see https://github.com/ossrs/srs/issues/375 * @see https://github.com/ossrs/srs/issues/375
@ -230,7 +224,6 @@ public:
*/ */
virtual bool is_segment_absolutely_overflow(); virtual bool is_segment_absolutely_overflow();
public: public:
virtual int update_acodec(SrsAudioCodecId ac);
/** /**
* whether current hls muxer is pure audio mode. * whether current hls muxer is pure audio mode.
*/ */
@ -278,7 +271,6 @@ public:
public: public:
virtual int initialize(); virtual int initialize();
virtual void dispose(); virtual void dispose();
virtual int update_acodec(SrsAudioCodecId ac);
virtual int sequence_no(); virtual int sequence_no();
virtual std::string ts_url(); virtual std::string ts_url();
virtual double duration(); virtual double duration();

View file

@ -31,7 +31,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// current release version // current release version
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 0 #define VERSION_MINOR 0
#define VERSION_REVISION 17 #define VERSION_REVISION 18
// generated by configure, only macros. // generated by configure, only macros.
#include <srs_auto_headers.hpp> #include <srs_auto_headers.hpp>

View file

@ -2740,12 +2740,6 @@ int SrsTsMuxer::open(string p)
return ret; return ret;
} }
int SrsTsMuxer::update_acodec(SrsAudioCodecId ac)
{
acodec = ac;
return ERROR_SUCCESS;
}
int SrsTsMuxer::write_audio(SrsTsMessage* audio) int SrsTsMuxer::write_audio(SrsTsMessage* audio)
{ {
int ret = ERROR_SUCCESS; int ret = ERROR_SUCCESS;
@ -3117,6 +3111,7 @@ int SrsTsEncoder::initialize(SrsFileWriter* fw)
writer = fw; writer = fw;
srs_freep(muxer); srs_freep(muxer);
// TODO: FIXME: Support config the codec.
muxer = new SrsTsMuxer(fw, context, SrsAudioCodecIdAAC, SrsVideoCodecIdAVC); muxer = new SrsTsMuxer(fw, context, SrsAudioCodecIdAAC, SrsVideoCodecIdAVC);
if ((ret = muxer->open("")) != ERROR_SUCCESS) { if ((ret = muxer->open("")) != ERROR_SUCCESS) {
@ -3140,12 +3135,6 @@ int SrsTsEncoder::write_audio(int64_t timestamp, char* data, int size)
return ret; return ret;
} }
// when codec changed, write new header.
if ((ret = muxer->update_acodec(format->acodec->id)) != ERROR_SUCCESS) {
srs_error("http: ts audio write header failed. ret=%d", ret);
return ret;
}
// for aac: ignore sequence header // for aac: ignore sequence header
if (format->acodec->id == SrsAudioCodecIdAAC && format->audio->aac_packet_type == SrsAudioAacFrameTraitSequenceHeader) { if (format->acodec->id == SrsAudioCodecIdAAC && format->audio->aac_packet_type == SrsAudioAacFrameTraitSequenceHeader) {
return ret; return ret;

View file

@ -1562,6 +1562,8 @@ protected:
class SrsTsMuxer class SrsTsMuxer
{ {
private: private:
// User must config the codec in right way.
// @see https://github.com/ossrs/srs/issues/301
SrsVideoCodecId vcodec; SrsVideoCodecId vcodec;
SrsAudioCodecId acodec; SrsAudioCodecId acodec;
private: private:
@ -1578,15 +1580,6 @@ public:
*/ */
virtual int open(std::string p); virtual int open(std::string p);
/** /**
* when open ts, we donot write the header(PSI),
* for user may need to update the acodec to mp3 or others,
* so we use delay write PSI, when write audio or video.
* @remark for audio aac codec, for example, SRS1, it's ok to write PSI when open ts.
* @see https://github.com/ossrs/srs/issues/301
*/
// TODO: FIXME: Remove it.
virtual int update_acodec(SrsAudioCodecId ac);
/**
* write an audio frame to ts, * write an audio frame to ts,
*/ */
virtual int write_audio(SrsTsMessage* audio); virtual int write_audio(SrsTsMessage* audio);