AirenSoft / OvenMediaEngine

OvenMediaEngine (OME) is a Sub-Second Latency Live Streaming Server with Large-Scale and High-Definition. #WebRTC #LLHLS
https://airensoft.com/ome.html
GNU Affero General Public License v3.0
2.61k stars 1.06k forks source link

Two typos and one semantic error in ffmpeg_writer.cpp #1386

Closed trapasso closed 1 year ago

trapasso commented 1 year ago
diff --git a/src/projects/modules/ffmpeg/ffmpeg_writer.cpp b/src/projects/modules/ffmpeg/ffmpeg_writer.cpp
index 9aee3ca6..efa5026f 100644
--- a/src/projects/modules/ffmpeg/ffmpeg_writer.cpp
+++ b/src/projects/modules/ffmpeg/ffmpeg_writer.cpp
@@ -87,8 +87,7 @@ namespace ffmpeg
                }

                _id_map[media_track->GetId()] = stream->index;
-               // _track_map[media_track->GetId()] = media_track;
-               _track_map[stream->index] = media_track;
+               _track_map[media_track->GetId()] = media_track;

                return true;
        }
@@ -178,16 +177,16 @@ namespace ffmpeg
                AVStream *av_stream = _av_format->streams[av_stream_index];
                if (!av_stream)
                {
-                       logtw("Could not find stream. av_stream_index(%d)", av_stream_index);
+                       logtw("Cloud not find stream. av_stream_index(%d)", av_stream_index);

                        return false;
                }

                // Find MediaTrack
-               auto media_track = _track_map[av_stream_index];
+               auto media_track = _track_map[packet->GetTrackId()];
                if (!media_track)
                {
-                       logtw("Could not find track. track_id(%d)", av_stream_index);
+                       logtw("Cloud not find track. track_id(%d)", packet->GetTrackId());

                        return false;
                }
@@ -320,4 +319,4 @@ namespace ffmpeg

                return true;
        }
-}  // namespace ffmpeg
+}  // namespace ffmpeg

very thanks.

Keukhan commented 1 year ago

https://github.com/AirenSoft/OvenMediaEngine/commit/c2dafa9ec1bb48d153680cef19783e696112461d Thanks :)

trapasso commented 1 year ago

Sorry but the semantic problem is due to the insertion index of the track, line 90:

// _track_map[media_track->GetId()] = media_track;
_track_map[stream->index] = media_track;

and it affects line 186:

// auto media_track = _track_map[packet->GetTrackId()];
auto media_track = _track_map[av_stream_index];

check if it comes back to you

Keukhan commented 1 year ago

There are no semantic errors in that code. However, the code was refactored due to lack of readability. :)

https://github.com/AirenSoft/OvenMediaEngine/compare/6231032b7256...d9316c73f9d8

trapasso commented 1 year ago

The index error was present. However, it's definitely better this way. :) Tested ... OK.

Thank you