2019-10-02 11:46:23 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
|
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2019-10-02 13:23:02 +03:00
|
|
|
#ifndef MOZILLA_FORWARDEDINPUTTRACK_H_
|
|
|
|
#define MOZILLA_FORWARDEDINPUTTRACK_H_
|
2019-10-02 11:46:23 +03:00
|
|
|
|
2019-10-02 13:23:02 +03:00
|
|
|
#include "MediaTrackGraph.h"
|
2019-10-02 11:46:23 +03:00
|
|
|
#include "nsAutoPtr.h"
|
|
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
|
|
|
|
/**
|
2019-10-02 13:23:02 +03:00
|
|
|
* See MediaTrackGraph::CreateForwardedInputTrack.
|
2019-10-02 11:46:23 +03:00
|
|
|
*/
|
2019-10-02 13:23:02 +03:00
|
|
|
class ForwardedInputTrack : public ProcessedMediaTrack {
|
2019-10-02 11:46:23 +03:00
|
|
|
public:
|
2019-10-02 13:23:02 +03:00
|
|
|
ForwardedInputTrack(TrackRate aSampleRate, MediaSegment::Type aType);
|
2019-10-02 11:46:23 +03:00
|
|
|
|
2019-10-02 13:23:02 +03:00
|
|
|
virtual ForwardedInputTrack* AsForwardedInputTrack() override { return this; }
|
2019-10-02 11:46:23 +03:00
|
|
|
friend class DOMMediaStream;
|
|
|
|
|
2019-10-02 13:22:53 +03:00
|
|
|
void AddInput(MediaInputPort* aPort) override;
|
2019-10-02 11:46:23 +03:00
|
|
|
void RemoveInput(MediaInputPort* aPort) override;
|
|
|
|
void ProcessInput(GraphTime aFrom, GraphTime aTo, uint32_t aFlags) override;
|
|
|
|
|
2019-10-02 13:22:53 +03:00
|
|
|
void SetEnabledImpl(DisabledTrackMode aMode) override;
|
2019-10-02 11:46:23 +03:00
|
|
|
|
2019-10-02 13:23:02 +03:00
|
|
|
friend class MediaTrackGraphImpl;
|
2019-10-02 11:46:23 +03:00
|
|
|
|
|
|
|
protected:
|
2019-10-02 13:23:02 +03:00
|
|
|
// Set up this track from a specific input.
|
2019-10-02 13:22:53 +03:00
|
|
|
void SetInput(MediaInputPort* aPort);
|
2019-10-02 11:46:23 +03:00
|
|
|
|
2019-10-02 13:22:53 +03:00
|
|
|
// MediaSegment-agnostic ProcessInput.
|
2019-10-02 13:23:02 +03:00
|
|
|
void ProcessInputImpl(MediaTrack* aSource, MediaSegment* aSegment,
|
2019-10-02 13:22:53 +03:00
|
|
|
GraphTime aFrom, GraphTime aTo, uint32_t aFlags);
|
2019-10-02 11:46:23 +03:00
|
|
|
|
2019-10-02 13:22:53 +03:00
|
|
|
void AddDirectListenerImpl(
|
2019-10-02 13:23:02 +03:00
|
|
|
already_AddRefed<DirectMediaTrackListener> aListener) override;
|
|
|
|
void RemoveDirectListenerImpl(DirectMediaTrackListener* aListener) override;
|
2019-10-02 11:46:23 +03:00
|
|
|
void RemoveAllDirectListenersImpl() override;
|
|
|
|
|
2019-10-02 13:22:53 +03:00
|
|
|
// These are direct track listeners that have been added to this
|
2019-10-02 13:23:02 +03:00
|
|
|
// ForwardedInputTrack-track. While an input is set, these are forwarded to
|
|
|
|
// the input track. We will update these when this track's disabled status
|
2019-10-02 13:22:53 +03:00
|
|
|
// changes.
|
2019-10-02 13:23:02 +03:00
|
|
|
nsTArray<RefPtr<DirectMediaTrackListener>> mOwnedDirectListeners;
|
2019-10-02 11:46:23 +03:00
|
|
|
|
2019-10-02 13:22:53 +03:00
|
|
|
// Set if an input has been added, nullptr otherwise. Adding more than one
|
|
|
|
// input is an error.
|
|
|
|
MediaInputPort* mInputPort = nullptr;
|
2019-10-02 11:46:23 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mozilla
|
|
|
|
|
2019-10-02 13:23:02 +03:00
|
|
|
#endif /* MOZILLA_FORWARDEDINPUTTRACK_H_ */
|