Commit Graph

74 Commits

Author SHA1 Message Date
JW Wang
c6e43291cb Bug 1376363. P3 - remove MediaResource::GetContentType() and its friends. r=gerald
Note we remove the call to mChannel->SetContentType() from RecreateChannel().

The hint never works as expected for [1] is the only caller to
nsIChannel::GetContentType() and MediaResource::Create() always happens
before any reads from the resource.

[1] http://searchfox.org/mozilla-central/rev/b425854d9bbd49d5caf9baef3686e49ec91c17ec/dom/media/MediaResource.cpp#1500

MozReview-Commit-ID: 1n4yHEouCjC

--HG--
extra : rebase_source : 9a7345c29b985ddee7a90a94191e9d526e2a0a67
extra : source : 054d9ffaf21eb937a6349df76228269ad2d7dc2c
2017-06-26 21:39:16 +08:00
JW Wang
a05b9a90ee Bug 1376360. P1 - give CloneData() a default implementation for most resource types don't support clone. r=gerald
Also remove CanClone() overrides that are identical to that of the base class.

MozReview-Commit-ID: A0Q5ychQtso

--HG--
extra : rebase_source : 3369558a8e6bc9f86ab6dcdc39fe40f686041001
2017-06-23 16:26:30 +08:00
Gerald Squelart
c486410640 Bug 1374180 - MediaResourceIndex won't use ReadFromCache, to keep MediaCache more consistent - r=cpearce
Bug 1368837 (Add lockless cache to MediaResourceIndex) used
MediaResource::ReadFromCache when trying to fill its local cache. But this
meant that these reads would not count as "real reads" for the MediaCache,
which could lead to unexpected states, e.g. "Played block after the current
stream position?"

To solve this, this patch reverts to using normal ReadAt() calls, which let
the MediaCache update itself properly.

While still trying to read more than what is requested (to hopefully fulfill
future reads from the local cache), we don't want to be reading so much that
we block waiting for data past the caller-expected point.
To do this, MediaResourceIndex::UncachedRangedReadAt() is called to try and
read as much as could fill the local cache, but if a single
MediaResource::ReadAt() ends before we can fill the local cache, but *after*
the minimum caller-requested size, we stop trying to read, as such extra read
is at risk of blocking (assuming that the caller knows not to read too far.)

MozReview-Commit-ID: 6fGvJpmkuLz

--HG--
extra : rebase_source : bf8e9f20599a05c8f3f221b55d678f0b5da447a9
2017-06-21 11:35:00 +12:00
JW Wang
4bc2a74510 Bug 1374566 - remove methods that have no callers. r=gerald
MozReview-Commit-ID: 7Ze0q32VS0h

--HG--
extra : rebase_source : 470fdf5d480b9115039faeb519756e05787011af
extra : source : be2cd2df4469cec5ded0f9d07977f8f09ba60cb6
2017-06-20 16:47:03 +08:00
JW Wang
09611a2a6e Bug 1373577. P3 - fix the comment since MediaResource::ReatAt() does update the offset of MediaResource. r=jya
MozReview-Commit-ID: AV2UhhBKNxJ

--HG--
extra : rebase_source : b8e03589a2712f3588de3226228e2b7b2b4d76cb
extra : source : 3d57529a2e1d7c628140968640ebc32d4409d3c9
2017-06-15 17:39:19 +08:00
JW Wang
aa62c9e3cc Bug 1373577. P2 - move the code of MediaResource::MediaReadAt() into MediaResourceIndex. r=jya
MediaReadAt() accesses only public members of MediaResource. It doesn't have
to be a member of MediaResource.

MozReview-Commit-ID: D7ByCLiAF4X

--HG--
extra : rebase_source : a25cdee55882c1a5da5816a21f600aab6d4491b3
extra : source : ecbf4d9750d7c0e34fe55208903f0712b4759023
2017-06-15 17:35:05 +08:00
JW Wang
8e98e3c0a2 Bug 1373577. P1 - devritualize MediaResource::MediaReadAt(). r=jya
The difference is the sub-class override doesn't call DispatchBytesConsumed().
It doesn't make sense not to call that after you do consume some data.
For callers that want silent reads, they should call ReadFromCache() instead.

MozReview-Commit-ID: J3dn8qgWKoL

--HG--
extra : rebase_source : 45f465e45ef3d67f989a3235dc1ddd76b11f1a81
extra : source : 9daf21e4c588e6cf13f3b28d8ffd8719573158c0
2017-06-15 17:17:08 +08:00
Gerald Squelart
74fb630e36 Bug 1369322 - MediaResourceIndex follows ShouldCacheReads recommendation - r=cpearce
MozReview-Commit-ID: A8mtz2fJd71

--HG--
extra : rebase_source : 81949d559c5482951ed9186c92d0759dd4a6b3b0
2017-06-02 16:10:48 +12:00
Gerald Squelart
caaa280433 Bug 1369322 - MediaResource::ShouldCacheReads to indicate usefulness of caching - r=cpearce
This hint will inform readers if caching is discouraged (e.g., for
SourceBufferResource) or recommmended (e.g., for MediaCache-backed
ChannelMediaResource).

MozReview-Commit-ID: 7hopNS0s5tE

--HG--
extra : rebase_source : 681646cc904229e8513adb148baa085254508049
2017-06-02 14:27:17 +12:00
JW Wang
49a7bff27a Bug 1367705. P3 - fix MediaChannelStatistics which no longer needs to be sharable. r=cpearce
MozReview-Commit-ID: 8guyyGquFnV

--HG--
extra : rebase_source : d4dcc146d3f7b36648cb06e3dc052ff648633821
extra : intermediate-source : ea621690a60d7b4208fddff7423747ea00ebeb4d
extra : source : a11e521f7f36cf8c8d31d7e6d52e0ea296306788
2017-06-02 12:44:43 +08:00
JW Wang
a8484aeb82 Bug 1367705. P2 - since RecordStatisticsTo() is removed in P1, we can now init mChannelStatistics in the constructor. r=cpearce
MozReview-Commit-ID: 5YcxnO368ex

--HG--
extra : rebase_source : bc0e757893de49fcdecf145b15fe13b194c23aa9
extra : intermediate-source : b4fd2265ca2652933fecf5502a4228a3bb0cd8f3
extra : source : 587479f45ef882571e5486b20b0b39dffe4d18fb
2017-06-02 11:51:52 +08:00
JW Wang
2688d70531 Bug 1367705. P1 - remove unused RecordStatisticsTo(). r=cpearce
This allows us to init mChannelStatistics in the constructor and
remove the possibility where we deref a null mChannelStatistics.

MozReview-Commit-ID: 9ZIRu0VXpd6

--HG--
extra : rebase_source : 741c8220e7e451b870aa9edd7d4006fd5c83eec4
extra : intermediate-source : 3cfd983577294749d85a4403724b42689f648df9
extra : source : a3f466b63da03a4989c799c169666bf0df937917
2017-06-02 11:10:38 +08:00
Gerald Squelart
8d4b44ad0f Bug 1368837 - Convert printfs into MOZ_LOG(MediaResourceIndex) - r=cpearce
MozReview-Commit-ID: Bhi1vxDPwDV

--HG--
extra : rebase_source : 4c66f796c5627ca85dbfbeab8ff40909a0249e7b
2017-05-30 14:12:38 +12:00
Gerald Squelart
0a2dc3ad21 Bug 1368837 - Replace debugging ReadAt with CachedReadAt code - r=cpearce
MozReview-Commit-ID: 88j9oAPdI0w

--HG--
extra : rebase_source : 7bf1da0b98eeaa871809c5c7386a7a26f99c7f29
2017-05-29 13:36:27 +12:00
Gerald Squelart
1bb5358dcf Bug 1368837 - media.cache.resource-index controls the MediaResourceIndex cache size - r=cpearce
8KB by default, otherwise using the next power of two from the given
media.cache.resource-index (but staying within 32B-128KB).
'0' means we don't want to use caching.

MozReview-Commit-ID: 8LmS15Ft2MA

--HG--
extra : rebase_source : 992f377a07b7ab173a64fcfbfe45df1da87df31e
2017-05-30 21:43:28 +12:00
Gerald Squelart
9e967498fe Bug 1368837 - MediaResourceIndex::ReadAt tries to cache last-read block - r=cpearce
This is the core of this bug:
- We try to read past the end of the requested range, and save a block-full of
cached data. ("Block" is a memory range, with an alignment and size being a
power of two, to match existing caching happening in MediaCache and
FileBlockCache, and to play nice with the memory allocator.)
- If part of a requested read touches the existing cache, we can just read from
the cache, which means we don't involve any of the locking and IOs that normal
reads use.

The small extra work needed to cache more data in some reads is largely offset
by all the lock&IO-heavy reads that we can subsequently avoid.

UncachedReadAt, which is used internally by CachedReadAt, is left public
because it could be useful if the caller knows for sure that a particular read
is isolated.

(Note: The printfs, and comparison code in ReadAt, will be removed in later
patches. Also the block size will be later controlled by a pref.)

MozReview-Commit-ID: GFiaP5Io7Hf

--HG--
extra : rebase_source : 2bebcdb7854989b55f2026e92338a00ac29a5376
2017-05-30 14:59:30 +12:00
Gerald Squelart
861a99455f Bug 1368837 - Document that MediaResource::GetCachedDataEnd should return aOffset when out of cache - r=cpearce
MozReview-Commit-ID: JKeuEAjIRxr

--HG--
extra : rebase_source : 93e2883833d47626f8d3abce4a151d93c0c106f1
2017-06-01 11:29:49 +12:00
JW Wang
c6c155a08e Bug 1364001. P1 - add an API to throttle download. r=cpearce
MozReview-Commit-ID: HdmAgvo1GE3

--HG--
extra : rebase_source : 97f0aa3e40c6c774ad7681ee2aae69393c47e741
extra : intermediate-source : 9f2e1751e19f88625d2a89dba0b1648f97d2478f
extra : source : b68fed514292e5e8c7815633052daeee24f64a95
2017-05-11 16:49:36 +08:00
JW Wang
240b996f12 Bug 1361964 - WebMBufferedState::UpdateIndex() should read from cache. r=jya
We don't want to trigger download when calculating buffer ranges since download
changes buffer ranges.

MozReview-Commit-ID: Be8qFUQ5PpR

--HG--
extra : rebase_source : 4fd77e031577332d9d112faef869cd935275b1af
2017-05-04 21:32:13 +08:00
JW Wang
84734bb3c0 Bug 1194891. P1 - plumb 'isPrivateBrowsing' down to MediaCacheStream. r=cpearce
MozReview-Commit-ID: EBKkOfK7K1p

--HG--
extra : rebase_source : 82daa16ffa0809a4de660867ab61d9a9efdf2a83
extra : source : b61d0c22837a6ee8085c95afbd1370ffa8286e6e
2017-04-06 16:20:00 +08:00
JW Wang
a7ba58c6c2 Bug 1353668. P1 - add a member function, CopySegmentToCache. r=kaku
MozReview-Commit-ID: 5uEWpMigspX

--HG--
extra : rebase_source : 51860bbc6e4de4f80045c774d3393158ff2251dd
extra : source : 9cb8013b0761a95eb0b30b83d05361a6d4dad7fd
2017-04-05 17:24:03 +08:00
Gerald Squelart
f17dd305d6 Bug 1331289 - Use MediaContainerType in MediaResource, SourceBuffer, TrackBuffersManager, and dependencies - r=jya
Continuing the work of replacing MIME strings with MediaContainerType, starting
from MediaResource and following the dependencies.

Most changes are mechanical: Just change ns*String into MediaContainerType, and
MIME string literals into MEDIAMIMETYPE("a/b").
Some checks for empty/invalid strings and lowercase comparisons can go, thanks
to the always-valid always-lowercase-MIME invariants of MediaContainerType.

One special case in is MediaSourceResource, which used to have an empty string
as its type (because its own type is not relevant, but its SourceBuffers carry
types). Because the inherited GetContentType *must* be overridden, and must
return a MediaContainerType, we needed a valid type even though it should not
be seen in the real world. I've chosen "application/x.mediasource" for that.

MozReview-Commit-ID: 1aCH75Kh2e6

--HG--
extra : rebase_source : 0d9cd9b69c264e5dcfc3845f80ee107f4bcbcd9a
2016-12-28 18:59:02 +11:00
Andrew McCreight
fccb0645ed Bug 1323042 - forbid MOZ_COUNT_{CTOR,DTOR} for nsISupports classes; r=froydnj 2016-12-12 09:27:58 -05:00
Nathan Froyd
826598caba Backout aba6c73511a2 (bug 1307961) for massive test bustage resulting in a CLOSED TREE; r=alltheorange 2016-12-12 08:45:46 -05:00
Andrew McCreight
e31b5489da Bug 1307961 - require consistent bloatview reporting for nsISupports classes; r=froydnj 2016-12-12 07:58:33 -05:00
bechen
931402dd2f Bug 1291629 - Remove RTSP code. r=jwwang
MozReview-Commit-ID: AxaLwO4rTuY

--HG--
extra : rebase_source : f8a5de1be1471238d62b6bbc419b3a45f2590da6
2016-08-10 10:32:25 +08:00
Nicholas Nethercote
3b0485fcdb Bug 1294645 - Don't use NS_CALLBACK for callbacks in nsI{Input,Output,UnicharInput},Stream.idl. r=froydnj.
Slightly less than half (93 / 210) of the NS_METHOD instances in the codebase
are because of the use of NS_CALLBACK in
nsI{Input,Output,UnicharInput},Stream.idl. The use of __stdcall on Win32 isn't
important for these callbacks because they are only used as arguments to
[noscript] methods.

This patch converts them to vanilla |nsresult| functions. It increases the size
of xul.dll by about ~600 bytes, which is about 0.001%.

--HG--
extra : rebase_source : c15d85298e0975fd030cd8f8f8e54501f453959b
2016-08-12 17:36:22 +10:00
JW Wang
d27b3f1144 Bug 1273063 - remove ChannelMediaResource::mIsTransportSeekable. r=cpearce.
MozReview-Commit-ID: DvBaIzbh72D

--HG--
extra : rebase_source : d507ef58c8556ee45be49668422c3843c92ed5bc
2016-05-17 10:33:34 +08:00
Jean-Yves Avenard
7a839f5456 Bug 1251044: P2. Remove dead code and generalise the use of content-range header. r=roc
MozReview-Commit-ID: ESMlcBOQKsy
2016-02-29 11:41:14 +11:00
Jean-Yves Avenard
bc55ba93a4 Bug 1240411: P9. Clean up media headers. r=jwwang
Remove redundant virtual keyword and add missing override if any.
2016-01-19 19:47:36 +11:00
Andrea Marchesini
7167daa292 summary: Bug 1231378 - part 5 - Fix uninitialized members of classes in dom/{workers,events,media,canvas}, r=smaug 2016-01-12 18:16:59 +00:00
Carsten "Tomcat" Book
00abd66130 Backed out changeset 6d08ab04a77c (bug 1231378) 2016-01-12 15:48:53 +01:00
Andrea Marchesini
98f16784c5 Bug 1231378 - part 5 - Fix uninitialized members of classes in dom/{workers,events,media,canvas}, r=smaug 2016-01-12 13:57:37 +00:00
Mike Hommey
58b657359f Bug 1225682 - Don't use nsAuto{,C}String as class member variables in dom/media/. r=cpearce 2015-12-02 11:04:37 +09:00
Jean-Yves Avenard
a7975b198f Bug 1227396: P8. Replace MediaByteRange with Interval<int64_t> typedef. r=cpearce
It's now okay to simplify.
2015-11-30 11:29:34 +11:00
Jean-Yves Avenard
c8c275cee2 Bug 1227396: P7. Replace nsTArray<MediaByteRange> with dedicated MediaByteRangeSet object. r=cpearce 2015-11-30 11:29:34 +11:00
Jean-Yves Avenard
98b7b59261 Bug 1227396: P6. Replace MediaByteBuffer with Interval<int64_t>. r=cpearce 2015-11-30 11:29:33 +11:00
Jean-Yves Avenard
70f2124283 Bug 1227396: P2. Rename some MediaByteRange methods. r=cpearce
Will facilitate the replacement of MediaByteRange by Interval<int64_t>
2015-11-30 11:29:30 +11:00
Jean-Yves Avenard
c92e468354 Bug 1227396: P1. Remove TimestampedMediaByteRange object. r=cpearce 2015-11-30 11:29:29 +11:00
JW Wang
c87926273d Bug 1221009. Part 1 - add a class to forward notifications from MediaResource to MediaDecoder. r=roc. 2015-11-16 07:50:55 +08:00
JW Wang
a7589ce310 Bug 1218280. Part 1 - create MediaResourceCallback for MediaResource to send notifications. r=roc. 2015-10-27 10:28:26 +08:00
Nathan Froyd
01583602a9 Bug 1207245 - part 6 - rename nsRefPtr<T> to RefPtr<T>; r=ehsan; a=Tomcat
The bulk of this commit was generated with a script, executed at the top
level of a typical source code checkout.  The only non-machine-generated
part was modifying MFBT's moz.build to reflect the new naming.

CLOSED TREE makes big refactorings like this a piece of cake.

 # The main substitution.
find . -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.mm' -o -name '*.idl'| \
    xargs perl -p -i -e '
 s/nsRefPtr\.h/RefPtr\.h/g; # handle includes
 s/nsRefPtr ?</RefPtr</g;   # handle declarations and variables
'

 # Handle a special friend declaration in gfx/layers/AtomicRefCountedWithFinalize.h.
perl -p -i -e 's/::nsRefPtr;/::RefPtr;/' gfx/layers/AtomicRefCountedWithFinalize.h

 # Handle nsRefPtr.h itself, a couple places that define constructors
 # from nsRefPtr, and code generators specially.  We do this here, rather
 # than indiscriminantly s/nsRefPtr/RefPtr/, because that would rename
 # things like nsRefPtrHashtable.
perl -p -i -e 's/nsRefPtr/RefPtr/g' \
     mfbt/nsRefPtr.h \
     xpcom/glue/nsCOMPtr.h \
     xpcom/base/OwningNonNull.h \
     ipc/ipdl/ipdl/lower.py \
     ipc/ipdl/ipdl/builtin.py \
     dom/bindings/Codegen.py \
     python/lldbutils/lldbutils/utils.py

 # In our indiscriminate substitution above, we renamed
 # nsRefPtrGetterAddRefs, the class behind getter_AddRefs.  Fix that up.
find . -name '*.cpp' -o -name '*.h' -o -name '*.idl' | \
    xargs perl -p -i -e 's/nsRefPtrGetterAddRefs/RefPtrGetterAddRefs/g'

if [ -d .git ]; then
    git mv mfbt/nsRefPtr.h mfbt/RefPtr.h
else
    hg mv mfbt/nsRefPtr.h mfbt/RefPtr.h
fi

--HG--
rename : mfbt/nsRefPtr.h => mfbt/RefPtr.h
2015-10-18 01:24:48 -04:00
Michael Layzell
0097c41e01 Bug 1201190 - Part 3: Mark every consumer of GUARD_OBJECT as MOZ_RAII, r=ehsan 2015-09-12 16:53:33 -04:00
Anthony Jones
434a36aad7 Bug 1142455 - Tweak MediaCache parameters. r=roc 2015-08-28 14:12:11 +12:00
Ryan VanderMeulen
593120864b Backed out changeset db8aa4fdcba4 (bug 1142455) for making bug 1179547 nearly permafail on OSX 10.6. 2015-08-30 18:38:14 -04:00
Anthony Jones
f7a8ee4dbc Bug 1142455 - Tweak MediaCache parameters; r=roc 2015-08-29 13:09:33 +12:00
Alastor Wu
e0d9476343 Bug 1187092 - Refactor the suspend process. r=jwwang
--HG--
extra : rebase_source : 8c8af14d6893c3813717aea19cf9a5d5ef4d53bd
2015-08-19 12:43:25 +08:00
Ryan VanderMeulen
0bb9f1e514 Backed out changeset ee800c0e234f (bug 1187092) for media crashes/asserts. 2015-08-18 13:11:05 -04:00
Alastor Wu
7ce5d8c0b5 Bug 1187092 - Refactor the suspend process. r=jwwang 2015-08-17 17:25:07 +08:00
Jean-Yves Avenard
5f8b09b58e Bug 1190238: P2. Have MediaResourceIndex::ReadAt() only stop early when reaching EOS or error. r=cpearce
MediaResource::ReadAt() requires to loop several times to ensure that all data has been read as it may return less data than requested.
This will allow to remove the handling of this particular shortcoming in MediaResources' users.
2015-08-13 15:27:09 +10:00