medea icon indicating copy to clipboard operation
medea copied to clipboard

Research Janus and Kurento inner design

Open alexlapa opened this issue 5 years ago • 3 comments

Kurento design

Kurento построен на gstreamer и унаследовал весь дизайн от него. Кодовую базу Kurento можно разделить на три части:

  1. gstremer plugins
  2. higher level abstractions
  3. json-rpc API, свой сборщик мусора и прочий обвес не представляющий интереса

Как работают плагины тут. В итоге, каждый плагин становится element, в терминологии gst.

Сейчас нам интереснее абстракции высшего уровня. Для начала немного о внутреннем дизайне gstreamer:

  1. Element - an element is the most important class of objects in GStreamer. An element has one specific function, which can be the reading of data from a file, decoding of this data or outputting this data to your sound card (or anything else).
  2. Pad - pads are element's input and output, where you can connect other elements. For the most part, all data in GStreamer flows one way through a link between elements. Data flows out of one element through one or more source pads, and elements accept incoming data through one or more sink pads. Source and sink elements have only source and sink pads, respectively.
  3. Bin - a bin is a container for a collection of elements. Since bins are subclasses of elements themselves, you can mostly control a bin as if it were an element, thereby abstracting away a lot of complexity for your application.
  4. Pipeline - a pipeline is a top-level bin. It provides a bus for the application and manages the synchronization for its children. As you set it to PAUSED or PLAYING state, data flow will start and media processing will take place. Once started, pipelines will run in a separate thread until you stop them or the end of the data stream is reached.

image

Все нагло скопировано отсюда

По похожей философии построены и внешние абстракции Kurento, единственное, что они достаточно удачно прячут все low-level details. У Kurento точно так-же есть базовый MediaElement с функцией connect(), но уровень абстракции его наследников значительно выше чем у элементов gstremer. Kurento MediaElement можно воспринимать как gstreamer bin.

Иерархия абстракций верхнего уровня:

mediaendpointdiagram

В итоге, получается достаточно удобное API. Но, главная фишка - сокрытие всех необходимых транскодирований/трансмуксирований. Соединяя два элемента, пользователь не переживает о совместимости их pad'ов:

One of the big problems of media is that the number of variants of video and audio codecs, formats and variants quickly creates high complexity in heterogeneous applications. So Kurento developed the concept of an automatic converter of media formats that enables development of agnostic elements. Whenever a media element’s source is connected to another media element’s sink, the Kurento framework verifies if media adaption and transcoding is necessary and, if needed, it transparently incorporates the appropriate transformations making possible the chaining of the two elements into the resulting Pipeline.

Считаю это решении достаточно удачным и предлагаю рассмотреть его или в качестве внешнего API или в качестве одного из внутренних слоев медиа-сервера.

alexlapa avatar Nov 09 '18 14:11 alexlapa